tybeady / ARBilliards

0 stars 0 forks source link

Projected Trajectory Math #1

Open tybeady opened 4 years ago

tybeady commented 4 years ago

We need code that will determine the projected trajectory of the object ball given the following:

  1. Location of the Cue Ball
  2. Location of the Object Ball
  3. Angle of the shot
  4. Radius of the Object Ball
tybeady commented 4 years ago

Given (CueX,CueY), (ObjX,ObjY), θp(Cue trajectory), and R(radius of the balls):

deltaX = ObjX - CueX
deltaY = ObjY - CueY
DirectLineLength = sqrt(deltaX^2 + deltaY^2)
θd(Direct line between Object and Cue) = atan2(deltaY,deltaX)*180/PI
deltaθ(ContactAngle) = θd - θp 

opposite the direct line is θc

Law of sines gives:
2R/sin(deltaθ) = DirectLineLength/sin(θc)

θc = asin((sin(deltaθ)*DirectLineLength)/2R)

θo (object ball trajectory) = 180 - θc + θp

This is my take on the base line math. hope this helps