예제 #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// 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;
    }
}
예제 #2
0
파일: Vec3D.hpp 프로젝트: sfegan/ChiLA
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /// 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);
 }
예제 #3
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// 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);
}