Point on line?
Anyone know how to check if a 3D point and a 3D line intersect (that is, the point is ON THE LINE)? Thanks.
Substitute the coordinates of the point in the line equations (e.g. parametric (x,y,z)=(x0,y0,z0)+t.(dx,dt,dz)) and look if it is a valid solution.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
Ok, so I just put x0, y0, z0 as the point and t.(dx, dy, dz) as the vector from point A to point B (the line segment vector)? If I do that, then what consists of a valid solution? Could you explain a little more. That would be great! Thanks.
Your line is a point (x0,y0,z0) and a vector (dx,dy,dz).
The point you''re testing is (x,y,z)
Find if there is a value t for which the equation is true.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
The point you''re testing is (x,y,z)
Find if there is a value t for which the equation is true.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
Hehe... Other solution:
Line is a point and a vector (lx, ly, lz for the point, lu, lv, lw for the vector). The vector should be lenght 1.
The point is simply a point (px, py, pz)
First, get the shortest distance from the line-point to the point-point:
distance = |(lx - px, ly - py, lz - pz)|.
Now the cool part: if the point is on the line, one of these two is true:
(lx, ly, lz) + (distance * (lu, lv, lw)) == (px, py, pz)
or
(lx, lym lz) + (-distance * (lu, lv, lw)) == (px, py, pz)
The point of this? Well, it ain't recursive! ^_^
[edited by - Ronin_54 on May 25, 2002 2:51:58 PM]
Line is a point and a vector (lx, ly, lz for the point, lu, lv, lw for the vector). The vector should be lenght 1.
The point is simply a point (px, py, pz)
First, get the shortest distance from the line-point to the point-point:
distance = |(lx - px, ly - py, lz - pz)|.
Now the cool part: if the point is on the line, one of these two is true:
(lx, ly, lz) + (distance * (lu, lv, lw)) == (px, py, pz)
or
(lx, lym lz) + (-distance * (lu, lv, lw)) == (px, py, pz)
The point of this? Well, it ain't recursive! ^_^
[edited by - Ronin_54 on May 25, 2002 2:51:58 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement