cee::Vec3f Class Reference

Vector class for a 3D float vector. More...

Public Member Functions

 Vec3f ()
 Constructs a null vector. More...
 
 Vec3f (const Vec3f &other)
 Constructs a vector as a copy of other. More...
 
 Vec3f (float x, float y, float z)
 Constructs a vector from an x, y and z coordinate. More...
 
Vec3foperator= (const Vec3f &other)
 Assigns other to this vector and returns a reference to this vector. More...
 
bool operator== (const Vec3f &rhs) const
 Returns true if two vectors are equal, otherwise returns false. More...
 
bool operator!= (const Vec3f &rhs) const
 Returns true if two vectors are not equal, otherwise returns false. More...
 
const Vec3f operator+ (const Vec3f &rhs) const
 Returns a vector that is this vector added with rhs. More...
 
const Vec3f operator- (const Vec3f &rhs) const
 Returns a vector that is this vector subtracted with rhs. More...
 
const Vec3f operator* (float scalar) const
 Returns a vector that is this vector multiplies with scalar. More...
 
const Vec3f operator/ (float scalar) const
 Returns a vector that is this vector divided with scalar. More...
 
Vec3foperator+= (const Vec3f &rhs)
 Adds the given rhs vector to this. More...
 
Vec3foperator-= (const Vec3f &rhs)
 Subtracts the given rhs vector from this. More...
 
Vec3foperator*= (float scalar)
 Multiplies every components of this vector with the given scalar. More...
 
Vec3foperator/= (float scalar)
 Divides every components of this vector with the given scalar. More...
 
float operator* (const Vec3f &rhs) const
 Computes the dot product of this and rhs and return the result (scalar) More...
 
const Vec3f operator^ (const Vec3f &rhs) const
 Computes the cross product of this and rhs and return the result (vector) More...
 
const float & x () const
 X element of the vector. More...
 
const float & y () const
 Y element of the vector. More...
 
const float & z () const
 Z element of the vector. More...
 
float & x ()
 X element of the vector. More...
 
float & y ()
 Y element of the vector. More...
 
float & z ()
 Z element of the vector. More...
 
void set (float x, float y, float z)
 Sets x, y and z value. More...
 
void transformPoint (const Mat4d &m)
 Transforms this point with the transformation matrix m. More...
 
void transformVector (const Mat4d &m)
 Transforms this vector with the transformation matrix m. More...
 
bool normalize ()
 Normalizes this vector. More...
 
float length () const
 Returns the length of this vector. More...
 
float angle (const Vec3f &other)
 Returns the angle (in radians) between this vector and the other. More...
 

Static Public Member Functions

static float dot (const Vec3f &v1, const Vec3f &v2)
 Returns the dot product of v1 and v2. More...
 
static Vec3f cross (const Vec3f &v1, const Vec3f &v2)
 Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2. More...
 

Detailed Description

Vector class for a 3D float vector.

Constructor & Destructor Documentation

cee::Vec3f::Vec3f ( )

Constructs a null vector.

cee::Vec3f::Vec3f ( const Vec3f other)

Constructs a vector as a copy of other.

cee::Vec3f::Vec3f ( float  x,
float  y,
float  z 
)

Constructs a vector from an x, y and z coordinate.

Member Function Documentation

float cee::Vec3f::angle ( const Vec3f other)

Returns the angle (in radians) between this vector and the other.

Vec3f cee::Vec3f::cross ( const Vec3f v1,
const Vec3f v2 
)
static

Returns the cross-product of vectors v1 and v2, which corresponds to the normal vector of a plane defined by v1 and v2.

float cee::Vec3f::dot ( const Vec3f v1,
const Vec3f v2 
)
static

Returns the dot product of v1 and v2.

Formula:

S = tx*rx + ty*ry + tz*rz
float cee::Vec3f::length ( ) const

Returns the length of this vector.

bool cee::Vec3f::normalize ( )

Normalizes this vector.

Returns false if the vector is a null vector. Otherwise returns true.

bool cee::Vec3f::operator!= ( const Vec3f rhs) const

Returns true if two vectors are not equal, otherwise returns false.

Exact comparison is used (!= between floats)

const Vec3f cee::Vec3f::operator* ( float  scalar) const

Returns a vector that is this vector multiplies with scalar.

float cee::Vec3f::operator* ( const Vec3f rhs) const

Computes the dot product of this and rhs and return the result (scalar)

Formula:

S = tx*rx + ty*ry + tz*rz
Vec3f & cee::Vec3f::operator*= ( float  scalar)

Multiplies every components of this vector with the given scalar.

const Vec3f cee::Vec3f::operator+ ( const Vec3f rhs) const

Returns a vector that is this vector added with rhs.

cee::Vec3f & cee::Vec3f::operator+= ( const Vec3f rhs)

Adds the given rhs vector to this.

const Vec3f cee::Vec3f::operator- ( const Vec3f rhs) const

Returns a vector that is this vector subtracted with rhs.

cee::Vec3f & cee::Vec3f::operator-= ( const Vec3f rhs)

Subtracts the given rhs vector from this.

const Vec3f cee::Vec3f::operator/ ( float  scalar) const

Returns a vector that is this vector divided with scalar.

Vec3f & cee::Vec3f::operator/= ( float  scalar)

Divides every components of this vector with the given scalar.

Vec3f & cee::Vec3f::operator= ( const Vec3f other)

Assigns other to this vector and returns a reference to this vector.

bool cee::Vec3f::operator== ( const Vec3f rhs) const

Returns true if two vectors are equal, otherwise returns false.

An exact match is required x() == rhs.x(), etc.

const Vec3f cee::Vec3f::operator^ ( const Vec3f rhs) const

Computes the cross product of this and rhs and return the result (vector)

Formula:

vec = <ty*rz - tz*ry, tz*rx - tx*rz, tx*ry - ty*rx>
void cee::Vec3f::set ( float  x,
float  y,
float  z 
)

Sets x, y and z value.

void cee::Vec3f::transformPoint ( const Mat4d m)

Transforms this point with the transformation matrix m.

void cee::Vec3f::transformVector ( const Mat4d m)

Transforms this vector with the transformation matrix m.

const float & cee::Vec3f::x ( ) const

X element of the vector.

float & cee::Vec3f::x ( )

X element of the vector.

const float & cee::Vec3f::y ( ) const

Y element of the vector.

float & cee::Vec3f::y ( )

Y element of the vector.

const float & cee::Vec3f::z ( ) const

Z element of the vector.

float & cee::Vec3f::z ( )

Z element of the vector.