Calculate components of a vector along a line

5 views (last 30 days)
Gianfranco
Gianfranco on 19 Aug 2014
Answered: Matt J on 19 Aug 2014
hello, i have 2 planes A and B, 2 points P1 (on plane A) and P2 (on plane B) and a vector v on plane B starting from point P2. I'm interested in calculating the components of the vector v along the line that passes by P1 and P2. Here is an image that could explain the situation:
How can I do this in Matlab? thanks!

Answers (2)

Chad Greene
Chad Greene on 19 Aug 2014
Do you have the x,y,z components of the two points? If yes, you could say that x2-x1 is the x component. You could then normalize this by dividing by the hypotenuse from point 1 to point 2.

Matt J
Matt J on 19 Aug 2014
dot(v,(P1-P2)/norm(P1-P2))

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!