From dd5ae2c395bdc2e677e086d46e52b76ef79bb6f3 Mon Sep 17 00:00:00 2001 From: Philippose Rajan Date: Sat, 11 Jul 2009 20:59:02 +0000 Subject: [PATCH] * Added "Dist" and "Dist2" functions to the Vec3d class --- libsrc/gprim/geom3d.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libsrc/gprim/geom3d.hpp b/libsrc/gprim/geom3d.hpp index 279e7e11..5339bc3a 100644 --- a/libsrc/gprim/geom3d.hpp +++ b/libsrc/gprim/geom3d.hpp @@ -255,6 +255,17 @@ public: double Length2() const { return x[0] * x[0] + x[1] * x[1] + x[2] * x[2]; } + /// + inline friend double Dist (const Vec3d & v1, const Vec3d & v2) + { return sqrt ( (v1.x[0]-v2.x[0]) * (v1.x[0]-v2.x[0]) + + (v1.x[1]-v2.x[1]) * (v1.x[1]-v2.x[1]) + + (v1.x[2]-v2.x[2]) * (v1.x[2]-v2.x[2])); } + /// + inline friend double Dist2 (const Vec3d & v1, const Vec3d & v2) + { return ( (v1.x[0]-v2.x[0]) * (v1.x[0]-v2.x[0]) + + (v1.x[1]-v2.x[1]) * (v1.x[1]-v2.x[1]) + + (v1.x[2]-v2.x[2]) * (v1.x[2]-v2.x[2])); } + /// Vec3d & operator+= (const Vec3d & v2); ///