###

» Tue Mar 17, 2015 3:58 am

Okay,

These are my givens:

v = (x,y)

v2 = ?

a = The angle between v and v2

I want to solve for the projection (P) of v onto v2.

I have two ways I can do this (that I know of).

a.)

P.X = (v.X * cos(a)) + (v.Y * sin (a))

P.Y = (v.X * cos(a+pi/2)) + (v.Y * sin(a+pi/2))

b.)

v2.magnitude = sqrt ( v2.X^2 + v2.Y ^2 )

v2.unitVector = v2 / v2.magnitude

DotProduct = v.X * v2.X + v.Y * v2.Y

P = DotProduct * v2.unitVector

Which is better? More efficient, etc...