* Added "Dist" and "Dist2" functions to the Vec3d class

This commit is contained in:
Philippose Rajan 2009-07-11 20:59:02 +00:00
parent 87e74276f3
commit dd5ae2c395

View File

@ -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);
///