Vector projection to other vector

4 replies · 2K views · last reply
twoski
Messages
177
Reaction score
2
Let's say i have 2 arbitrary vectors in a 3d space. I want to project Vector A to Vector B using a specified normal.

edit: better image

Diagram of a black parallelogram drawn in perspective, with a red arrow pointing up from its centre, a red dot at the base of the arrow, a green dot above a blue dot on the left with a light blue arrow pointing down between them.


A is green, B is red, C is red arrow. Blue is result.

In this case, i want to project green vector to red vector in the red direction. This would give me the blue vector as a result.

I'm working in unity and they have a projection function, but it doesn't operate how i want it to... So i guess i need to make my own.

Here is the projection function they do have: https://docs.unity3d.com/ScriptReference/Vector3.Project.html
 
Attachments
  • Diagram of a flat rhombus-shaped plane in perspective with a blue arrow pointing straight up from its top corner, a red dot near the centre, and a pink vertical line segment with a purple dot at its top on the right side.
    nlUJHEW.png
    5.9 KB · Views: 447
  • Diagram of a black parallelogram drawn in perspective, with a red arrow pointing up from its centre, a red dot at the base of the arrow, a green dot above a blue dot on the left with a light blue arrow pointing down between them.
    PQh2BdO.png
    1.5 KB · Views: 845
Last edited:
  • Like
Likes   Reactions: Delta2
The drawing is really bad. Can you try to explain what are you trying to do mathematically ?

As I understand you have three vectors, ##\vec {A},\vec {B},\vec {C}## you want to project ##\vec {A}## on ##\vec {B}##. on direction ##\vec {C}## ?

Isnt it the same as A projection on C ? Since A projection on B gives you a vector on B direction and then you want to project it again on C ?

If this is true I can help you with the code part. I guess at least for the math part.
 
Sorry that's not a great picture. A and B are 2 vectors in a 3d Space. I want to project Vector B to Vector A in a given direction, ie. Normalized Vector C.