2D collision equations with inverse y-axis I am currently trying to code a 2D physics engine in gamemaker studio, however I have run into a problem.
I have found the following useful website to help me calculate the new x and y components of my speed vector after collision:
http://williamecraver.wixsite.com/elastic-equations
EDIT:
I'll try and be more specific about my problem:
I want to calculate collision in 2D. In order to do this I first rotate my x-y axis so that x runs from the centre of one object through the center of the other object (both are circles). (the image in the link nicely illustrates the situation)
In the link I provide, calculation of resulting vx and vy vectors for each object after the collision is explained.
It uses the following equations to rotate the vx and vy components(I'm sorry I don't know how to insert proper equations)
vxr = v * cos(theta - phi)
vyr = v * sin(theta - phi)
with vxr being the rotated vx vector (same for vy), theta being my original angle between v and the x axis, phi being my rotation angle
Then these "rotated" vx and vy components are inserted into the equations for conservation of momentum and kinetic energy to solve a 1D collision (which is possible because of the rotation of the axis). Afterwards he rotates the axis back using the following equations:
vfx = vfxr * cos(phi) + vyr * cos(phi + pi/2)
vfy = vfyr * sin(phi) + vyr * sin(phi + pi/2)
with vfxr/vfyr being the resulting rotated x/y component after collision, vfx vfy being the resulting x/y components transformed back into the regular x-y plane.
My problem is that my y-axis is pointing down (instead of the conventional up). Therefore I believe the original equations for vyr should be:
vyr = v * -sin(theta - phi)
My first question is if my assumption for the vyr component is correct and if I missed other things that should change in the calculation because of the inverted y-axis. What about the equation to rotate vx and vy back to the regular x-y plane?
Secondly, if my assumptions are correct, I am unable to perform the calculations when inserting these equations into the 1D collision equations. Especially regarding the conversion back to regular x-y plane, I don't understand where these equations come from and how they change with an inverse y-axis.
 A: Hence the problem with doing this problem using angles. I suggest you use vectors and basic vector manipulations to get the same result. In my convention, a vector quantity is boldfaced and its magnitude italicised. For example $$ \begin{align} \mathbf{v} & = \pmatrix{v_x \\ v_y} & v = \| \mathbf{v} \| = \sqrt{v_x^2+v_y^2} \end{align} $$

*

*Establish the direction of the contact ${\bf n}$. For balls use the center to center vector. If the two centers have coordinates $\mathbf{r}_1$ and $\mathbf{r}_2$, then $$\mathbf{n} = \frac{ \mathbf{r}_2 - \mathbf{r}_1 }{ \| \mathbf{r}_2 - \mathbf{r}_1 \| } $$

*Get the reduced mass $m$ of the system. If the two masses are $m_1$ and $m_2$ then $$m = \left( \frac{1}{m_1} + \frac{1}{m_2} \right)^{-1} = \frac{m_1 m_2}{m_1 + m_2} $$

*Get the impact speed. This is the relative speed along the direction of the contact $$v_{imp} = \mathbf{n} \cdot (\mathbf{v}_1 - \mathbf{v}_2) $$ where $\cdot$ is the vector dot product.

*Decide what the coefficient of restitution $\epsilon$ shall be. For perfectly elastic collisions use, $\epsilon=1$.

*Calculate the total momentum exchanged (a.k.a. impulse). This is a scalar quantity  $$ J = (1+\epsilon) m \, v_{imp} $$

*Calculate the final velocities after impact from the impulse

$$\begin{align} \mathbf{v}_1^f & = \mathbf{v}_1 - \frac{J}{m_1} \mathbf{n} \\
\mathbf{v}_2^f & = \mathbf{v}_2 + \frac{J}{m_2} \mathbf{n} \end{align} $$
That is it. You have yourself a proper 2D collision model regardless of the convention of which way the x and y axes go. As long as you are consistent with the components of the positions and velocities, the rest works out on its own. :-)
