0

Given the image below, I am trying to find the degrees I need to rotate the curve itself, to get A (x1, y1) to point B (x2, y2). I need this rotation to animate a circle along a path for the web (writing the animations in code).

Image

  • 1
    What format do you have the coordinates and circle in? – Zach Saucier Apr 27 at 0:34
3

You must know the centerpoint of the circle. Otherwise there's infinite number of possible circles common for A and B.

Think the points as complex numbers A=x1+iY1, B=x2+iY2. In the same way let the centerpoint of the circle be C=x3+iy3

radius B-C = (A-C)exp(iD) where D=the needed rotation from A to B in radians. Thus you calculate (B-C)/(A-C), convert the result to polar form and get the needed angle as the angle of the polar presentation. The result is seen as CCW direction.

No actual division is needed. As well you convert A-C and B-C both to polar form and subtract the angles to get the difference.

  • I find it simpler to use {sin, cos} but ok – joojaa Apr 27 at 7:58
  • it's subjectively simpler, but the final calculation is the same. Complex numbers do not need help drawings which easily introduce invalid assumptions of the directions and angle sizes. – user287001 Apr 27 at 8:01
  • I agree but the reason i use sin, cos is that i find sin cos more useful in other circumstances so i dont need to carry around 2 separate notations – joojaa Apr 27 at 8:03

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.