1

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)

2 Answers2

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

Clear[angle]
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 *)

LouisB
  • 12,528
  • 1
  • 21
  • 31
2

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

Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55