mvVec3 Class Reference

vector class used in mvMotionAI library for 3D motion More...

#include <mvVec3.h>

List of all members.

Public Member Functions

void AcrossB (const mvVec3 &a, const mvVec3 &b)
 in place cross product
mvFloat cosineMeasure (const mvVec3 &v) const
 cosine measure - angle between two vectors
mvVec3 cross (const mvVec3 &rhs) const
 cross product
mvFloat dot (const mvVec3 &v) const
 dot product
const mvFloatgetPointer () const
 returns XYZ array pointer
mvFloat getX () const
 returns X
mvFloat getY () const
 returns Y
mvFloat getZ () const
 returns Z
mvFloat length (void) const
 length of vector
mvFloat lengthSquared (void) const
 length squared
 mvVec3 (const mvVec3 &rhs)
 constructor
 mvVec3 (const mvFloat *array)
 constructor
 mvVec3 (const mvFloat &X, const mvFloat &Y, const mvFloat &Z)
 constructor
 mvVec3 (void)
 constructor
mvVec3 normalize (void) const
 normalize: returns normalized version
mvFloat normalizedDotProduct (const mvVec3 &v) const
 normalized dot product -
mvVec3 operator * (const mvFloat s) const
 vector times scalar product (scale length of vector times argument)
const mvVec3operator *= (const mvFloat &s)
 *= (scaled by constant then assigned)
bool operator!= (const mvVec3 &v) const
 vector inequality
mvVec3 operator+ (const mvVec3 &v) const
 vector addition through + operator
const mvVec3operator+= (const mvFloat &s)
 += adds constant mvFloat to all members
const mvVec3operator+= (const mvVec3 &v)
 += (add togwther and assignment)
mvVec3 operator- (void) const
 unary minus or negates vector (-v)
mvVec3 operator- (const mvVec3 &v) const
 vector subtraction through - operator
const mvVec3operator-= (const mvFloat &s)
 -= subtracts constant mvFloat to all members
const mvVec3operator-= (const mvVec3 &v)
 -= (calculate differemce them assigmed)
mvVec3 operator/ (const mvFloat s) const
 vector divided by a scalar (divide length of vector by argument)
const mvVec3operator/= (const mvFloat &s)
 /= divides constant float to all members
const mvVec3operator= (const mvVec3 &v)
 assignment
bool operator== (const mvVec3 &v) const
 vector equality
const mvVec3set (const mvFloat _x, const mvFloat _y, const mvFloat _z)
 set XYZ coordinates to given three mvFloats
void setX (const mvFloat &x)
 set x component of vector
void setY (const mvFloat &y)
 set y component of vector
void setZ (const mvFloat &z)
 set z component of vector
void toZeroVec ()
 reset vector


Detailed Description

vector class used in mvMotionAI library for 3D motion

this class contains an array of mvFloat (or floating variables) which are used to store details such as position, velocity and force in 3D space.


Constructor & Destructor Documentation

mvVec3::mvVec3 ( void   ) 

constructor

default value of vector is (0,0,0)

mvVec3::mvVec3 ( const mvFloat X,
const mvFloat Y,
const mvFloat Z 
) [explicit]

constructor

Parameters:
[in] X x value of vector
[in] Y y value of vector
[in] Z z value of vector
value of vector will be (X,Y,Z)

mvVec3::mvVec3 ( const mvFloat array  )  [explicit]

constructor

Parameters:
[in] array pointer to a mvFloat array of length 3 (or MV_VEC3_NO_OF_COMPONENTS)
value of mvVec3 should be (array[0],array[1],array[2])

mvVec3::mvVec3 ( const mvVec3 rhs  ) 

constructor

Parameters:
[in] rhs another mvVec3
value of mvVec3 should be equal to rhs


Member Function Documentation

void mvVec3::AcrossB ( const mvVec3 a,
const mvVec3 b 
)

in place cross product

Parameters:
[in] a Vector on Left hand side of equation
[in] b Vector on Right hand side of equation
Result is saved in 'this' vector that is crose product of a & b (i.e modifies "*this" to be A x B) Vectors a & b is unchanged by function. Result is not normalised

mvFloat mvVec3::cosineMeasure ( const mvVec3 v  )  const

cosine measure - angle between two vectors

Parameters:
[in] v Vector to multiplied with current vector
Returns:
result as a mvFloat.
Returns the result of arccos (cos-1) value of of the dot product of the two normalized vectors a & v as a mvFloat. Formula: if a = this vector, b = vector v c.m = arccos[ (a . b )/ (|a||b|) ] Original vectors v & a is unchanged by dot function.

mvVec3 mvVec3::cross ( const mvVec3 rhs  )  const

cross product

Parameters:
[in] rhs Right hand side of equation
Returns:
mvVec3 of cross product
Returns new instance of mvVec3 which contains the result of cross product. Vectors 'this' & 'rhs' is unchanged by function. Result is not normalised

mvFloat mvVec3::dot ( const mvVec3 v  )  const

dot product

Parameters:
[in] v Vector to multiplied with current vector
Returns:
result as a mvFloat.
NOTE : vectors are not normalised in function

Returns the total of the dot product of the two vectors a & v as a mvFloat. Dot product is calculated by result = a.x * v.x + a.y * v.y + a.z * v.z Original vectors v & a is unchanged by dot function.

const mvFloat * mvVec3::getPointer (  )  const

returns XYZ array pointer

Returns:
const mvFloat array pointer of length 3

mvFloat mvVec3::length ( void   )  const

length of vector

Returns:
mvFloat of vector length
Formula : l = sqrt(x2 + y2 + z2)

mvFloat mvVec3::lengthSquared ( void   )  const

length squared

Returns:
mvFloat of vector length squared
Formula : l . sq = (x2 + y2 + z2)

mvVec3 mvVec3::normalize ( void   )  const

normalize: returns normalized version

Returns:
mVec3 parallel to original, with unit length of 1
NOTE : skip divisiom (i.e normalization) if length is zero

mvFloat mvVec3::normalizedDotProduct ( const mvVec3 v  )  const

normalized dot product -

Parameters:
[in] v Vector to multiplied with current vector
Returns:
result as a mvFloat.
Returns the result of dot product of the two normalized vectors a & v as a mvFloat.

Formula: if a = this vector, b = vector v n.d.p = (a . b )\ (|a||b|) Original vectors v & a is unchanged by dot function.

mvVec3 mvVec3::operator * ( const mvFloat  s  )  const

vector times scalar product (scale length of vector times argument)

Parameters:
[in] s Scalar value as a mvFloat value.
Returns:
new instance of mvVec3
Returns the vector (x * s,y * s,z * s) as a new instance of mvVec3. Original vector v is unchanged and can be nested with more operations.

const mvVec3 & mvVec3::operator *= ( const mvFloat s  ) 

*= (scaled by constant then assigned)

Parameters:
[in] s Constant mvFloat value
Returns:
C++ mvVec3 reference of modified vector
Returns the modified vector with the values of (x * s,y * s, z * s)

bool mvVec3::operator!= ( const mvVec3 v  )  const

vector inequality

Parameters:
[in] v Vector to be compared
Returns:
boolean i.e true or false

mvVec3 mvVec3::operator+ ( const mvVec3 v  )  const

vector addition through + operator

Parameters:
[in] v Vector on right hand side of + operator
Returns:
new instance of mvVec3
Returns new instance of mvVec3 that is the result of two mvVec3 vectors (C++ reference or instance) alongside the + operator added together and does not change either vectors. Can be nested with more operations.

const mvVec3 & mvVec3::operator+= ( const mvFloat s  ) 

+= adds constant mvFloat to all members

Parameters:
[in] s Constant mvFloat value
Returns:
C++ mvVec3 reference of modified vector
Returns the modified vector with the values of (x + s,y + s, z + s)

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

+= (add togwther and assignment)

Parameters:
[in] v Vector to be added
Returns:
C++ mvVec3 reference of modified vector
Returns the modified vector with the values of (x + v.x,y + v.y, z+ v.z)

mvVec3 mvVec3::operator- ( void   )  const

unary minus or negates vector (-v)

Returns:
new instance of mvVec3
Returns the current vector's v(a,b,c) negation, which is (-a,-b,-c), as a new mvVec instance. Original vector v is unchanged.

mvVec3 mvVec3::operator- ( const mvVec3 v  )  const

vector subtraction through - operator

Parameters:
[in] v Vector on right hand side of - operator
Returns:
new instance of mvVec3
Returns new instance of mvVec3 that is the result of left hand mvVec3 vector (C++ reference or instance) subtract right side vector (v) of the - operator and does not change either vectors. Can be nested with more operations.

const mvVec3 & mvVec3::operator-= ( const mvFloat s  ) 

-= subtracts constant mvFloat to all members

Parameters:
[in] s Constant mvFloat value
Returns:
C++ mvVec3 reference of modified vector
Returns the modified vector with the values of (x - s,y - s, z - s)

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

-= (calculate differemce them assigmed)

Parameters:
[in] v Subtracting Vector
Returns:
C++ mvVec3 reference of modified vector
Returns the modified vector with the values of (x - v.x,y - v.y, z - v.z)

mvVec3 mvVec3::operator/ ( const mvFloat  s  )  const

vector divided by a scalar (divide length of vector by argument)

Parameters:
[in] s Scalar value as a mvFloat value.
Returns:
new instance of mvVec3
Returns the vector (x/s,y/s,z/s) as a new instance of mvVec3. Original vector v is unchanged and can be nested with more operations. Does not handle division by zero errors.

const mvVec3 & mvVec3::operator/= ( const mvFloat s  ) 

/= divides constant float to all members

Parameters:
[in] s Constant mvFloat value
Returns:
C++ mvVec3 reference of modified vector
Returns the modified vector with the values of (x / s,y / s, z / s) NOTE: division by zero not handled

const mvVec3 & mvVec3::operator= ( const mvVec3 rhs  ) 

assignment

Parameters:
[in] rhs Vector of right side of assignment (=)
Returns:
C++ mvVec3 reference of vector
Set the left hand side (this) to equal the right hand side vector rhs. Vector rhs is unaffected by fucntion

bool mvVec3::operator== ( const mvVec3 v  )  const

vector equality

Parameters:
[in] v Vector to be compared
Returns:
boolean i.e true or false

const mvVec3 & mvVec3::set ( const mvFloat  _x,
const mvFloat  _y,
const mvFloat  _z 
)

set XYZ coordinates to given three mvFloats

Parameters:
[in] _x X component parameter
[in] _y Y component parameter
[in] _z Z component parameter
Returns:
C++ mvVec3 reference of vector
Returns the modified vector with the values of (_x,_y,_z)

void mvVec3::setX ( const mvFloat x  ) 

set x component of vector

Parameters:
[in] x X component value

void mvVec3::setY ( const mvFloat y  ) 

set y component of vector

Parameters:
[in] y Y component value

void mvVec3::setZ ( const mvFloat z  ) 

set z component of vector

Parameters:
[in] z Z component value

void mvVec3::toZeroVec (  ) 

reset vector

set all members to zero


The documentation for this class was generated from the following files:
Generated on Wed Nov 14 17:05:00 2007 for mvMotionAI by  doxygen 1.5.3