Skip to content
Advertisement

using python to calculate Vector Projection

Is there an easier command to compute vector projection? I am instead using the following:

JavaScript

Advertisement

Answer

Maybe this is what you really want:

JavaScript

This should give the projection of vector x onto vector y – see https://en.wikipedia.org/wiki/Vector_projection. Alternatively, if you want to compute the projection of y onto x, then replace y with x in the denominator (norm) of the above equation.

EDIT: As @VaidAbhishek commented, the above formula is for the scalar projection. To obtain vector projection multiply scalar projection by a unit vector in the direction of the vector onto which the first vector is projected. The formula then can be modified as:

JavaScript

for the vector projection of x onto y.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement