Reputation: 37
I have three 3D points, just say p1, p2, and p3. I am able to make a line that connects p1 and p2. Then, the p3 will be in between the p1 and p2 but not collinear. I want to know if the p3 is close to the line. How to check it?
Upvotes: 1
Views: 172
Reputation: 12287
You're just finding the height of a triangle. Fortunately you can instantly google the formula:
https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
Again, the formula is widely available
https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
Here's the bible that all game programmers have to memorize by heart!
http://amazon.com/Mathematics-Programming-Computer-Graphics-Third/dp/1435458869
Upvotes: 0