X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGRay.hxx;h=eef28cc46beadbae5ae2582fbddf0e7045fd3d1a;hb=7beaf3705ec3e58abc7c5d06b31a5e8724102de1;hp=afd7b0413f11d27449e51a0b8f480576cd7959c5;hpb=bbd61977f14c30ce93a2bcf5a3551708d36a29c8;p=simgear.git 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;