In video game physics, collisions are a fundamental aspect that determines how objects interact with each other. Understanding the different types of collisions is crucial for creating realistic and engaging game environments. This section will cover the primary types of collisions, their characteristics, and how they are typically handled in game development.
- Elastic Collisions
Definition
Elastic collisions are collisions where both momentum and kinetic energy are conserved. This means that the total kinetic energy of the system (all objects involved in the collision) remains the same before and after the collision.
Characteristics
- Conservation of Momentum: The total momentum of the colliding objects remains constant.
- Conservation of Kinetic Energy: The total kinetic energy remains unchanged.
- No Permanent Deformation: Objects do not deform permanently; they return to their original shape after the collision.
Example
Consider two billiard balls colliding on a pool table. The balls bounce off each other without losing kinetic energy.
Mathematical Representation
For two objects with masses \( m_1 \) and \( m_2 \), and velocities \( v_1 \) and \( v_2 \) before the collision, and \( v_1' \) and \( v_2' \) after the collision:
\[ m_1 v_1 + m_2 v_2 = m_1 v_1' + m_2 v_2' \] \[ \frac{1}{2} m_1 v_1^2 + \frac{1}{2} m_2 v_2^2 = \frac{1}{2} m_1 v_1'^2 + \frac{1}{2} m_2 v_2'^2 \]
Code Example
def elastic_collision(m1, v1, m2, v2): v1_prime = (v1 * (m1 - m2) + 2 * m2 * v2) / (m1 + m2) v2_prime = (v2 * (m2 - m1) + 2 * m1 * v1) / (m1 + m2) return v1_prime, v2_prime # Example usage: m1, v1 = 2.0, 3.0 # mass and velocity of object 1 m2, v2 = 1.0, -1.0 # mass and velocity of object 2 v1_prime, v2_prime = elastic_collision(m1, v1, m2, v2) print(f"New velocities: v1' = {v1_prime}, v2' = {v2_prime}")
- Inelastic Collisions
Definition
Inelastic collisions are collisions where momentum is conserved, but kinetic energy is not. Some of the kinetic energy is converted into other forms of energy, such as heat or sound, or is used to deform the colliding objects.
Characteristics
- Conservation of Momentum: The total momentum of the colliding objects remains constant.
- Loss of Kinetic Energy: Some kinetic energy is lost in the form of heat, sound, or deformation.
- Permanent Deformation: Objects may deform permanently as a result of the collision.
Example
A car crash where the vehicles crumple and kinetic energy is converted into heat and sound.
Mathematical Representation
For two objects with masses \( m_1 \) and \( m_2 \), and velocities \( v_1 \) and \( v_2 \) before the collision, and \( v_1' \) and \( v_2' \) after the collision:
\[ m_1 v_1 + m_2 v_2 = m_1 v_1' + m_2 v_2' \] \[ \frac{1}{2} m_1 v_1^2 + \frac{1}{2} m_2 v_2^2 > \frac{1}{2} m_1 v_1'^2 + \frac{1}{2} m_2 v_2'^2 \]
Code Example
def inelastic_collision(m1, v1, m2, v2, restitution): v1_prime = (m1 * v1 + m2 * v2 + m2 * restitution * (v2 - v1)) / (m1 + m2) v2_prime = (m1 * v1 + m2 * v2 + m1 * restitution * (v1 - v2)) / (m1 + m2) return v1_prime, v2_prime # Example usage: m1, v1 = 2.0, 3.0 # mass and velocity of object 1 m2, v2 = 1.0, -1.0 # mass and velocity of object 2 restitution = 0.8 # coefficient of restitution v1_prime, v2_prime = inelastic_collision(m1, v1, m2, v2, restitution) print(f"New velocities: v1' = {v1_prime}, v2' = {v2_prime}")
- Perfectly Inelastic Collisions
Definition
Perfectly inelastic collisions are a special case of inelastic collisions where the colliding objects stick together after the collision, moving with a common velocity.
Characteristics
- Conservation of Momentum: The total momentum of the colliding objects remains constant.
- Maximum Loss of Kinetic Energy: The maximum possible amount of kinetic energy is lost.
- Objects Stick Together: The colliding objects move as a single entity after the collision.
Example
Two pieces of clay colliding and sticking together.
Mathematical Representation
For two objects with masses \( m_1 \) and \( m_2 \), and velocities \( v_1 \) and \( v_2 \) before the collision, and common velocity \( v' \) after the collision:
\[ m_1 v_1 + m_2 v_2 = (m_1 + m_2) v' \]
Code Example
def perfectly_inelastic_collision(m1, v1, m2, v2): v_prime = (m1 * v1 + m2 * v2) / (m1 + m2) return v_prime # Example usage: m1, v1 = 2.0, 3.0 # mass and velocity of object 1 m2, v2 = 1.0, -1.0 # mass and velocity of object 2 v_prime = perfectly_inelastic_collision(m1, v1, m2, v2) print(f"Common velocity after collision: v' = {v_prime}")
Practical Exercise
Exercise
- Problem Statement: Two objects with masses 3 kg and 2 kg are moving towards each other with velocities 4 m/s and -3 m/s, respectively. Calculate their velocities after an elastic collision.
- Solution:
- Use the elastic collision formula to find the new velocities.
Solution Code
def elastic_collision(m1, v1, m2, v2): v1_prime = (v1 * (m1 - m2) + 2 * m2 * v2) / (m1 + m2) v2_prime = (v2 * (m2 - m1) + 2 * m1 * v1) / (m1 + m2) return v1_prime, v2_prime # Given data m1, v1 = 3.0, 4.0 # mass and velocity of object 1 m2, v2 = 2.0, -3.0 # mass and velocity of object 2 # Calculate new velocities v1_prime, v2_prime = elastic_collision(m1, v1, m2, v2) print(f"New velocities: v1' = {v1_prime}, v2' = {v2_prime}")
Feedback on Common Mistakes
- Incorrect Application of Conservation Laws: Ensure both momentum and kinetic energy conservation laws are correctly applied in elastic collisions.
- Ignoring Masses: Always consider the masses of the objects involved in the collision calculations.
- Sign Convention: Pay attention to the direction of velocities (positive or negative) as they indicate direction.
Conclusion
Understanding the different types of collisions and their characteristics is essential for simulating realistic interactions in video games. Elastic collisions conserve both momentum and kinetic energy, inelastic collisions conserve momentum but not kinetic energy, and perfectly inelastic collisions result in the objects sticking together. By mastering these concepts, you can create more immersive and physically accurate game environments.
Physics of Video Games
Module 1: Introduction to Physics in Video Games
Module 2: Kinematics and Dynamics
- Uniform Rectilinear Motion (URM)
- Uniformly Accelerated Rectilinear Motion (UARM)
- Newton's Laws
- Circular Motion
Module 3: Collisions and Responses
Module 4: Rigid Bodies Physics
- Introduction to Rigid Bodies
- Rigid Bodies Simulation
- Interactions between Rigid Bodies
- Constraints and Joints