Finding vector components along a unit vector without calculating size?

35 Views Asked by At

How do you find out the components of a vector in the direction of a unit vector without calculating the size of the original vector in the process?

If V is the vector and U is the unit vector then to get the component of V (say Vc) in direction of U , the straight forward way seems to be following:

S = Sqrt(V.x^2 + V.y^2 + V.z^2)

Vc = (S * U.x)i + (S * U.y)j + (S * U.z)k

In this approach you need to find the size of V which involves finding a square root which is computationally expensive and time consuming.

Are there any simpler methods to get Vc from V with less computation?