demo.mp4
The momentum of an object:
The kinetic energy of an object:
Considering the 2-object system as a closed system:
-
Conservation of momentum:
$$m_1v_1 + m_2v_2 = m_1v_1' + m_2v_2'$$ -
Conservation of kinetic energy:
$$\frac{m_1v_1^2}{2} + \frac{m_2v_2^2}{2} = \frac{m_1v_1'^2}{2} + \frac{m_2v_2'^2}{2}$$
Combining these two equations gives the velocities after collisions of object 1 and 2:
Let
Spliting the velocity vectors of the two objects into the vectors which are normal and tangent to the surface of the collision:
Normal vector:
The unit normal vector:
The unit tangent vector:
The
After the collision, the tangential component of the velocities is unchanged because there is no force along the line tangent to the collision surface and the normal component of the velocities can be found using the one-dimensional collision formulas presented above.
The unit normal vector is multiplied by the scalar (plain number) normal velocity after the collision to get a vector which has a direction normal to the collision surface and a magnitude which is the normal component of the velocity after the collision.
Let
Let
The tangential components of the velocity do not change after the collision because there is no force between the circles in the tangential direction during the collision:
The normal component of the velocities can be found using the one-dimensional collision formulas presented above:
Multiplying the unit normal vector by the scalar normal velocity to you get a vector which has a direction that is normal to the surfaces at the point of collision and a magnitude equal to the normal component of the velocity. It is similar for the tangential component:
The final velocity vectors by adding the normal and tangential components for each object:
A quadtree is a tree data structure in each node represents a rectangular region of space, which is recursively subdivided into four smaller regions: NW, NE, SW, SE. This process continues until each region contains a manageable number of objects.
In collision detection, a quadtree helps efficiently manage and query spatial data. When checking for collisions, objects are inserted into the quadtree based on their spatial location. Each object's bounding box determines its placement within the appropriate quadrant.
When querying for potential collisions, the quadtree is traversed starting from the root. Only the nodes (quadrants) that intersect with the object's bounding box are examined. This selective examination helps in quickly identifying and processing only those objects that are near each other, thereby optimizing collision detection and improving performance in large-scale simulations.
The complexity of processing collision detection using query quadtree: