//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Method to return a normalized direction vector inline Vec3D Vec4D::GetDirection() { if(r.Norm2()==0.) { return r; } else { VEC3D_T norm = r.Norm(); Vec3D r1 = r/norm; return r1; } }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Method for reflection of vector in mirror inline void Vec3D::Reflect(const Vec3D& norm) //!reflect in normal { double n2 = norm.Norm2(); if(n2 == 0)return; *this -= norm * (2.0*((*this)*norm)/n2); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// Method for reflection of vector in mirror inline void Vec3D::Reflect(const Vec3D& norm) //!reflect in normal { VEC3D_T n2 = norm.Norm2(); if(n2 == (VEC3D_T)(0.0))return; *this -= norm * ((VEC3D_T)(2.0)*((*this)*norm)/n2); }