Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Given point P, find the point on the line defined by A and B that is closest to point B
  2. vector getClosetPoint(vector A, vector B, vector P)
  3. {
  4.     vector AP = P - A;
  5.     vector AB = B - A;
  6.     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));
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement