Original Post
Hey guys, I''m working on a collision detection routine and had a question regarding the algorithm listed on this page (http://www.gamedev.net/reference/articles/article1026.asp) for the closestPointOnLine function:
Point closestPointOnLine(Point a, Point b, Point p)
{
// Determine t (the length of the vector from ‘a’ to ‘p’)
Vector c = p - a;
Vector V = Normalized vector [b – a];
double d = distance from a to b;
double t = V * c;
// Check to see if ‘t’ is beyond the extents of the line segment
if (t < 0) return a;
if (t > d) return b;
// Return the point between ‘a’ and ‘b’
set length of V to t;
return a + V;
}
On the double t = V * c; line.. it''s multiplying V * c, which are both vectors. Which implys that they''re taking the Dot Product, right?