Vector3 Class Reference
[libbiarc]

The Vector3 class is a 3 dimensional Vector class with floating point coordinates. More...

#include <include/Vector3.h>

List of all members.

Public Member Functions

 Vector3 ()
 Vector3 (const float x, const float y, const float z)
 Vector3 (const float v[3])
 Vector3 (const Vector3 &v)
 ~Vector3 ()
float & operator[] (const int c)
const float & operator[] (const int c) const
Vector3zero ()
void getValues (float &X, float &Y, float &Z) const
Vector3setValues (const float X, const float Y, const float Z)
Vector3setValues (const float v[3])
float dot (const Vector3 &v) const
Vector3 cross (const Vector3 &v) const
float norm () const
float norm2 () const
Vector3normalize ()
float max ()
float min ()
Vector3 reflect (const Vector3 &v) const
Vector3 rotPtAroundAxis (float angle, Vector3 axis) const
Vector3 operator* (const Vector3 &v) const
Vector3 operator+ (const Vector3 &v) const
Vector3 operator- (const Vector3 &v) const
Vector3 operator- () const
Vector3operator+= (const Vector3 &v)
Vector3operator-= (const Vector3 &v)
Vector3operator*= (const float s)
Vector3operator/= (const float s)
int operator== (const Vector3 &v) const
int operator!= (const Vector3 &v) const
void print (ostream &out) const

Static Public Attributes

static const unsigned int type = 3

Friends

Vector3 operator* (const Vector3 &v, float d)
Vector3 operator* (float d, const Vector3 &v)
Vector3 operator/ (const Vector3 &v, float d)
ostream & operator<< (ostream &out, const Vector3 &v)
istream & operator>> (istream &in, Vector3 &v)


Detailed Description

The Vector3 class is a 3 dimensional Vector class with floating point coordinates.

This class provides storage for a 3 dimensional vector aswell as arithmetic operations on vectors, like the dot product, the cross product, the length of the vector.


Constructor & Destructor Documentation

Vector3::Vector3 (  ) 

Constructs an empty vector initialized to zero.

See also:
zero().

Referenced by cross(), operator*(), operator+(), and operator-().

Vector3::Vector3 ( const float  x,
const float  y,
const float  z 
)

Constructs a Vector3 instance from x, y and z.

Vector3::Vector3 ( const float  v[3]  ) 

Constructs a Vector3 with initial values from v.

Vector3::Vector3 ( const Vector3 v  ) 

Constructs a copy of v.

Vector3::~Vector3 (  ) 

The destructor has nothing to do


Member Function Documentation

float & Vector3::operator[] ( const int  c  )  [inline]

Index operator. Returns modifiable x, y or z coordinate of the vector.

See also:
getValue() and setValue().

float Vector3::operator[] ( const int  c  )  const [inline]

Index operator. Returns x, y or z coordinate of vector.

See also:
getValue() and setValue().

Vector3 & Vector3::zero (  ) 

Sets all vector components to zero

Referenced by Matrix3::Matrix3(), and Matrix3::zero().

void Vector3::getValues ( float &  X,
float &  Y,
float &  Z 
) const

Recover the vector components and put them into X, Y and Z.

Vector3 & Vector3::setValues ( const float  X,
const float  Y,
const float  Z 
)

Set the vector to <X,Y,Z>. Returns a reference to itself.

Vector3 & Vector3::setValues ( const float  v[3]  ) 

Set new coordinates from the given array v. Returns a reference to itself.

float Vector3::dot ( const Vector3 v  )  const

Returns the dot product between the current vector and v.

References _v.

Referenced by Tube< Vector >::makeMesh(), Curve< Vector >::normalVector(), Biarc< Vector >::pointOnArc0(), Biarc< Vector >::pointOnArc1(), and rotPtAroundAxis().

Vector3 Vector3::cross ( const Vector3 v  )  const

Returns a vector w, that is the result of the cross product between the actual vector and a vector v.

returns $w=a\times v$

References _v, and Vector3().

Referenced by Tube< Vector >::makeMesh().

float Vector3::norm (  )  const

Computes and returns the length of the vector.

$|v|=\sqrt{x^2+y^2+z^2}.$

See also:
norm2(), normalize().

Referenced by normalize(), Biarc< Vector >::pointOnArc0(), and Biarc< Vector >::pointOnArc1().

float Vector3::norm2 (  )  const

Computes and returns the squared norm of the vector.

$|v|^2=x^2+y^2+z^2.$

See also:
norm(), normalize().

Referenced by Matrix3::cay().

Vector3 & Vector3::normalize (  ) 

Normalizes the current vector and returns a reference to itself

If the vector has zero norm, a warning message is posted to the error output and the Vector3 is Not modified.

See also:
norm(), norm2().

References norm().

Referenced by Tube< Vector >::makeMesh(), Biarc< Vector >::pointOnArc0(), Biarc< Vector >::pointOnArc1(), reflect(), and Matrix3::rotAround().

float Vector3::max (  ) 

Returns the largest component of the current vector.

float Vector3::min (  ) 

Returns the smallest component of the current vector.

Vector3 Vector3::reflect ( const Vector3 ref_ax  )  const

Returns the mirror vector according to the given axe ref_ax. The reference axe needs not to be normalized, since this is done automatically.

References normalize(), and Matrix3::outer().

Vector3 Vector3::rotPtAroundAxis ( float  angle,
Vector3  axis 
) const

Rotate the current point at <x,y,z> around the given rotational axes axis and an angle angle. The value for the angle is given in radians.

References dot().

Referenced by Tube< Vector >::makeMesh().

Vector3 Vector3::operator* ( const Vector3 v  )  const

Returns a Vector3 that is the dot product of this vector and v.

References _v, and Vector3().

Vector3 Vector3::operator+ ( const Vector3 v  )  const

Sum of the vector with v.

References Vector3().

Vector3 Vector3::operator- ( const Vector3 v  )  const

Returns the difference between this vector and v.

References Vector3().

Vector3 Vector3::operator- (  )  const

Returns a new Vector3 that points in the opposite direction.

References Vector3().

Vector3 & Vector3::operator+= ( const Vector3 v  ) 

Adds the vector v to this vector and returns an instance to itself.

Vector3 & Vector3::operator-= ( const Vector3 v  ) 

Substracts the vector v from this vector and returns an instance to itself.

Vector3 & Vector3::operator*= ( const float  s  ) 

Assign operator. Does the same as the copy constructor.

Multiplies this vector's components by s and returns an instance to itself.

Vector3 & Vector3::operator/= ( const float  s  ) 

Divides this vector's components by s and returns an instance to itself.

int Vector3::operator== ( const Vector3 v  )  const

Comparison operator. Returns 1 if the current vector and v are the same. Returns 0 otherwise.

int Vector3::operator!= ( const Vector3 v  )  const

If the current vector and v are not equal, this function returns 1, and 0 otherwise.

void Vector3::print ( ostream &  out  )  const

Prints the components of this vector in a formatted way onto the stream out.


Friends And Related Function Documentation

Vector3 operator* ( const Vector3 v,
float  d 
) [friend]

Returns a Vector3 that is this vector scaled by a scalar s.

Returns a Vector3 that is the vector v scaled by a scalar d.

Vector3 operator* ( float  d,
const Vector3 v 
) [friend]

Returns a Vector3, that is the vector v scaled by a scalar s.

Vector3 operator/ ( const Vector3 v,
float  d 
) [friend]

Returns a Vector3 whose components are divided by d.

Friend function that returns the vector v whose components are scaled by d.

ostream & Vector3::operator<< ( ostream &  out,
const Vector3 v 
) [friend]

Overloaded left shift operator. Returns the Vector v as an ostream that can be written to a file or to standart output.

See also:
print() operator>>()

ostream & Vector3::operator>> ( istream &  out,
Vector3 v 
) [friend]

Overloaded right shift operator. Initialize vector v with istream out.

See also:
print() operator<<()


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

Generated on Mon Feb 8 17:22:36 2010 for libbiarc by  doxygen 1.5.6