Search code examples
c#mathvectorgame-enginegame-physics

Get Angle Between Two Vectors On A Circle


I've a P1,P2 and P3 vectors and I need to angle. It has to positive. For instance α = 30, θ=270

enter image description here

Have can I calculate P1->P2;α or p1->P3;θ ?


Solution

  • Related Wikipedia article: Dot product

    By calculating the dot product of the two vectors and then dividing by the product of their magnitudes, you get cos(angle). Using acos, you can then extract the angle.