1
\$\begingroup\$

Ball collision

I know Q3 + Q4 = 90

I searched internet and many physic topics, but not found how to calculate this values in Java?

(I found V3 and V4 but not found Q3 and Q4)

So how can i calculate V3, V4, Q3, Q4 values after the collision in Java?

\$\endgroup\$
  • \$\begingroup\$ It seems like you just want to simulate elastic collision \$\endgroup\$ – newton1212 Jun 17 '15 at 13:55
  • \$\begingroup\$ @newton1212 no, elastic collision is "center collision", so the balls are always collision the center line. But i want angled collision like billiards phsics. In your tuts+ link the collisions is not realistic If you look carefully. The balls is always behaving as center collision. So my (V1) direction is not intersect with (V2)'s center, because they are collision with angle \$\endgroup\$ – MarsPeople Jun 17 '15 at 15:22
  • \$\begingroup\$ There's no such thing as spheres colliding anywhere other than their centers. The only thing that can change is the angle of the line from center to center. \$\endgroup\$ – Seth Battin Jul 3 '15 at 21:31
  • \$\begingroup\$ Also, is this a homework problem? That's the only reason I can think of why you would state a specific sum of Q3 and Q4, but demand their values. Their value is whatever it is; aren't you interested in the general solution? \$\endgroup\$ – Seth Battin Jul 3 '15 at 21:33
  • \$\begingroup\$ I am not student, I am game programmer i just can't calculate the values for make "angled collision billiard" game \$\endgroup\$ – MarsPeople Jul 3 '15 at 22:24
1
\$\begingroup\$

So, you want the angle of velocity relative to the x-axis? That'd be atan(V3.y/V3.x) and atan(V4.y/V4.x) for Q3 and Q4, respectively.

Though, since the balls are almost aligned along the y-axis in relation to each other, it looks like maybe you're looking for the angle of V3/V4 relative to the surface at the point of impact, even when that doesn't line up with the x-axis.

In that case, you need the normal of impact (most collision functions will give you this as some of the output, but it's easy for spheres/circles anyway -- just normalise ball1.xy - ball2.xy). Anyway, you can use that normal and V3 to calculate Q3 like so:

acos(DotProduct(normal, V3.Normalised())).

It'll vary a little depending on what libraries you're using, but basically: the dot product of two normalised vectors (that is, vectors with a magnitude of 1) will be the cos of the angle between the vectors. Apply the inverse cos function (acos) and you get the angle between them.

For Q4, replace "V3" with "V4".

\$\endgroup\$
1
\$\begingroup\$

It's much simpler than you think:

Just use the "relative velocity" to calculate the impulse

relVel = vB - vA;

Then, use it to project against the normal to find the impulse.

normal = (posB-posA) / Length(posB-posA);

coefficient_of_restituition = 0; // (100% energy lost)
coefficient_of_restituition = 1; // (0% energy lost)

impulse = -(1 + coefficient_of_restituition) * dot(relVel, Normal) / (invMassA + invMassB);
\$\endgroup\$
-1
\$\begingroup\$

maby this can help you http://en.wikipedia.org/wiki/Coefficient_of_restitution there is a break down of the entire problem

\$\endgroup\$
  • \$\begingroup\$ How can i calculate Q3, Q4? \$\endgroup\$ – MarsPeople Apr 17 '15 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.