Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Given point P, find the point on the line defined by A and B that is closest to point B
- vector getClosetPoint(vector A, vector B, vector P)
- {
- vector AP = P - A;
- vector AB = B - A;
- return A + AB * ((AP.x*AB.x + AP.y*AB.y + AP.z*AB.z) / (AB.x*AB.x + AB.y*AB.y + AB.z*AB.z));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement