Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a point is on a 3d line?

I know how to check if a point is on a 2d line or not, but I'd like to do this in 3D. Any ideas?

        // slope from point 1 to point 3
        var p13:Number = (Math.atan2 (end.x - start.x, end.y - start.y)) * toDegrees;

        // slope from point 1 to point 2 -- matches?
        var p12:Number = (Math.atan2 (point.x - start.x, point.y - start.y)) * toDegrees;

        return Math.round(p12) == Math.round(p13);
like image 607
Robin Rodricks Avatar asked Feb 18 '11 16:02

Robin Rodricks


1 Answers

Normalize the vectors. Check if the normals match.

Find the greatest value, divide all of the other values by that value so you get a vector normal.

Any point on a line should have the same vector normal.

like image 193
Lee Louviere Avatar answered Sep 16 '22 18:09

Lee Louviere