diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Geometry/Ray.cpp |
Diffstat (limited to 'Runtime/Geometry/Ray.cpp')
-rw-r--r-- | Runtime/Geometry/Ray.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Runtime/Geometry/Ray.cpp b/Runtime/Geometry/Ray.cpp new file mode 100644 index 0000000..0dac305 --- /dev/null +++ b/Runtime/Geometry/Ray.cpp @@ -0,0 +1,17 @@ +#include "UnityPrefix.h" +#include "Ray.h" + +float Ray::SqrDistToPoint(const Vector3f& P) const { +//ΚΚΚ Vector v = L.P1 - L.P0; + Vector3f v = m_Direction; +// Vector3f w = P - L.P0; + Vector3f w = P - m_Origin; + + float c1 = Dot(w,v); + float c2 = Dot(v,v); + float b = c1 / c2; + +//ΚΚΚ Point Pb = L.P0 + b * v; + Vector3f Pb = GetPoint (b); + return SqrMagnitude(P - Pb); +} |