Assuming, Point A=vector2( 210,400) B=vector2(-120,480)

Is there a short formula to find the angle to rotate A towards B ? (A is currently heading towards the Y-axis)

Currently, using Pythagorean theorem by getting quadrant info for third point (A.x,B.y) or (B.x,A.y). Then acos... Little complicated.

Respecting A if if B.x>A.x then quadrant=1. Assuming C=(A.x,B.y) Rotation=acos(AC/BC)

  • $\begingroup$ VectorAngle? $\endgroup$
    – Lukas Lang
    Dec 25, 2022 at 18:37
  • $\begingroup$ Are you intereseted in a formula, say for mathematical interest, or are you trying to solve for the actual angle? VectorAngle is the easiest way to get the latter. In your specific case, VectorAngle[vecA, vecB] will do the trick (where vecA={210,400} and vecB={-120,480}. Apply N to get a finite precision value. $\endgroup$
    – lericr
    Dec 25, 2022 at 19:07
  • $\begingroup$ @lericr VectorAngle[vecA, vecB]? Is it a function we can call in lua or python? $\endgroup$ Dec 25, 2022 at 22:12
  • $\begingroup$ Possible duplicate better-way-to-calculate-angle-between-lines $\endgroup$
    – chyanog
    Dec 26, 2022 at 13:07

2 Answers 2


VectorAngle returns the same value for rotating $\vec{a}$ to $\vec{b}$ as it does for rotating $\vec{b}$ to $\vec{a}$. If you want a formula for the signed angle, try this

angle[v1_, v2_] := Arg[Complex @@ v2] - Arg[Complex @@ v1]

Example usage:

{a, b} = {{210, 400}, {-120, 480}};

angle[a, b]/Degree // N   (* 41.735716276 *)

angle[b, a]/Degree // N   (* -41.735716276 *)

Alternative- Real-version(2D)

ArcTan[a . b, Det[{a, b}]]/Degree//N (* 41.7357*)
ArcTan[b . a, Det[{b, a}]]/Degree//N (* -41.7357*) 

or ArcTan[a . b, Cross[ a]. b ]/Degree


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