Back to index

extremetuxracer  0.5beta
Public Member Functions | Public Attributes | Friends
pp::Vec3d Class Reference

A 3D vector class. More...

#include <vec3d.h>

List of all members.

Public Member Functions

 Vec3d ()
 Vec3d (const double x, const double y, const double z)
 Vec3d (const double *v)
double normalize ()
double length () const
double length2 () const

Public Attributes

double x
double y
double z

Friends

Vec3d operator+ (const Vec3d &vec1, const Vec3d &vec2)
Vec3d operator- (const Vec3d &vec1, const Vec3d &vec2)
Vec3d operator* (const Vec3d &vec, const double scalar)
Vec3d operator* (const double scalar, const Vec3d &vec)
double operator* (const Vec3d &vec1, const Vec3d &vec2)
Vec3d operator^ (const Vec3d &vec1, const Vec3d &vec2)

Detailed Description

A 3D vector class.

Definition at line 28 of file vec3d.h.


Constructor & Destructor Documentation

Definition at line 27 of file vec3d.cpp.

 : x(0.0), y(0.0), z(0.0)
{
}
pp::Vec3d::Vec3d ( const double  x,
const double  y,
const double  z 
)

Definition at line 32 of file vec3d.cpp.

 : x(x), y(y), z(z)
{
}
pp::Vec3d::Vec3d ( const double *  v)

Definition at line 37 of file vec3d.cpp.

 : x(v[0]), y(v[1]), z(v[2])
{
}

Member Function Documentation

double pp::Vec3d::length ( ) const

Definition at line 57 of file vec3d.cpp.

{
       return sqrt(x*x+y*y+z*z);
}

Here is the caller graph for this function:

double pp::Vec3d::length2 ( ) const

Definition at line 63 of file vec3d.cpp.

{
       return x*x+y*y+z*z;
}

Here is the caller graph for this function:

Definition at line 44 of file vec3d.cpp.

{
    double len = length();
       if (len>0.0)
       {
              x /= len;
              y /= len;
              z /= len;
       }                
       return(len);
};

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

Vec3d operator* ( const Vec3d vec,
const double  scalar 
) [friend]

Definition at line 81 of file vec3d.cpp.

{
       return Vec3d(vec.x*scalar,vec.y*scalar,vec.z*scalar);
}
Vec3d operator* ( const double  scalar,
const Vec3d vec 
) [friend]

Definition at line 87 of file vec3d.cpp.

{
       return Vec3d(vec.x*scalar,vec.y*scalar,vec.z*scalar);
}
double operator* ( const Vec3d vec1,
const Vec3d vec2 
) [friend]

Definition at line 93 of file vec3d.cpp.

{
       return vec1.x*vec2.x+vec1.y*vec2.y+vec1.z*vec2.z;
}
Vec3d operator+ ( const Vec3d vec1,
const Vec3d vec2 
) [friend]

Definition at line 69 of file vec3d.cpp.

{
       return Vec3d(vec1.x+vec2.x,vec1.y+vec2.y,vec1.z+vec2.z);
}
Vec3d operator- ( const Vec3d vec1,
const Vec3d vec2 
) [friend]

Definition at line 75 of file vec3d.cpp.

{
       return Vec3d(vec1.x-vec2.x,vec1.y-vec2.y,vec1.z-vec2.z);
}
Vec3d operator^ ( const Vec3d vec1,
const Vec3d vec2 
) [friend]

Definition at line 99 of file vec3d.cpp.

{
       return Vec3d(
              vec1.y * vec2.z - vec1.z * vec2.y,
              vec1.z * vec2.x - vec1.x * vec2.z,
              vec1.x * vec2.y - vec1.y * vec2.x
       );
}

Member Data Documentation

double pp::Vec3d::x

Definition at line 35 of file vec3d.h.

double pp::Vec3d::y

Definition at line 36 of file vec3d.h.

double pp::Vec3d::z

Definition at line 37 of file vec3d.h.


The documentation for this class was generated from the following files: