summaryrefslogtreecommitdiff
path: root/Runtime/Geometry/Ray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Geometry/Ray.cpp')
-rw-r--r--Runtime/Geometry/Ray.cpp17
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);
+}