- #1
Tynged
- 2
- 0
I am working on an implementation of the Gilbert–Johnson–Keerthi distance algorithm and am having difficulty with some of the more general math involved.
I am able to find the projection of a point onto a plane because I'm given at least three points on the plane and the point that is to be projected. I can form two vectors given the three points on the plane and take the cross product of those two vectors to create a vector orthogonal to both vectors in addition to the plane.
I am unsure how to do this when projecting a point onto a line, however. I know two points on the line and the point that is to be projected. There are an infinite number of vectors perpendicular to this line, but the one that also goes through the given point not on the line should be the vector I'm looking for.
I'd also like to note that I am using a single data structure to represent both points and vectors in 3-space. A structure containing the data {0, 0, 0} could represent a point at the origin or a vector with zero magnitude. A structure containing the data {3,4,0} could represent a point where x=3, y=4, and z=0 or it could represent a vector whose tail is at the origin and whose head is at the point where x=3, y=4, and z=0. In the implementation I am using, vector tails are always placed at the origin, and vector heads are placed at the given x,y,z coordinate. This makes it a little more difficult to think about the problem, for me at least.
I am able to find the projection of a point onto a plane because I'm given at least three points on the plane and the point that is to be projected. I can form two vectors given the three points on the plane and take the cross product of those two vectors to create a vector orthogonal to both vectors in addition to the plane.
I am unsure how to do this when projecting a point onto a line, however. I know two points on the line and the point that is to be projected. There are an infinite number of vectors perpendicular to this line, but the one that also goes through the given point not on the line should be the vector I'm looking for.
I'd also like to note that I am using a single data structure to represent both points and vectors in 3-space. A structure containing the data {0, 0, 0} could represent a point at the origin or a vector with zero magnitude. A structure containing the data {3,4,0} could represent a point where x=3, y=4, and z=0 or it could represent a vector whose tail is at the origin and whose head is at the point where x=3, y=4, and z=0. In the implementation I am using, vector tails are always placed at the origin, and vector heads are placed at the given x,y,z coordinate. This makes it a little more difficult to think about the problem, for me at least.