[ad_1]
Game Development Stack Exchange is a query and reply web site for skilled and unbiased sport builders. It solely takes a minute to enroll.
Anybody can ask a query
Anybody can reply
The finest solutions are voted up and rise to the highest
Asked
Viewed
9 instances
I’m making an attempt to determine the speed of ball A after collision which is V2.A as seen within the determine. I do know that the speed of ball A when collision happens is perpendicular to the road connecting centre of ball A and B when the collision happens.

(Image taken from: http://www.real-world-physics-problems.com/physics-of-billiards.html)
Issue is, my V2.A is typically flipped in wrong way, and I can not appear to determine the difficulty right here. Here’s my V2.A calculation
Vector2 diff = (b - a).normalized;
Vector2 perpendiular = Vector2.Perpendicular(diff);
Thank you!
$endgroup$
Returns the 2D vector perpendicular to this 2D vector. The result’s all the time rotated 90-degrees in a counter-clockwise course for a 2D coordinate system the place the optimistic Y axis goes up.
In this case, simply choose whether or not the unsigned angle between the speed vector of ball A and the outcome vector is larger than 90 levels:
Vector2 diff = (b - a).normalized;
Vector2 perpendiular = Vector2.Perpendicular(diff);
if (Vector2.Angle(directionOfA, perpendiular) > 90)
{
perpendiular = -perpendiular;
}
$endgroup$
You should log in to reply this query.
Not the reply you are searching for? Browse different questions tagged .
lang-cs
[ad_2]