diff --git a/simgear/math/SGRay.hxx b/simgear/math/SGRay.hxx index afd7b041..eef28cc4 100644 --- a/simgear/math/SGRay.hxx +++ b/simgear/math/SGRay.hxx @@ -47,6 +47,12 @@ public: SGVec3 getNormalizedDirection() const { return normalize(getDirection()); } + SGVec3 getClosestPointTo(const SGVec3& point) + { + SGVec3 u(getNormalizedDirection()), + v(point - _origin); + return (dot(u, v) * u) + _origin; + } private: SGVec3 _origin; SGVec3 _direction;