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