From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Geometry/Ray.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Runtime/Geometry/Ray.cpp (limited to 'Runtime/Geometry/Ray.cpp') 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); +} -- cgit v1.1-26-g67d0