Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
Menge::Math::Vector3d< Type > Class Template Reference

Templated vector in R3. More...

#include <Vector3.h>

Public Member Functions

 Vector3d ()
 Default constructor. It does NOT initialize the fields.
 
 Vector3d (Type x, Type y, Type z)
 Constructor with arguments. More...
 
 Vector3d (const Vector3d &v)
 Copy constructor. More...
 
Type x () const
 Get the x-value. More...
 
Type y () const
 Get the y-value. More...
 
Type z () const
 Get the z-value. More...
 
void set (Type x, Type y, Type z)
 Set the x- and y-values from scalar values. More...
 
void set (const Vector3d &v)
 Set the x-, y- and z-values from a vector. More...
 
void setX (Type x)
 Set the x-value. More...
 
void setY (Type y)
 Set the y-value. More...
 
void setZ (Type z)
 Set the z-value. More...
 
Type operator[] (const int i) const
 Index-style access to vector components. More...
 
Type & operator[] (const int i)
 Index-style access to vector components as a reference. More...
 
void zero ()
 Set the vector to zero.
 
Vector3d< Type > operator- () const
 Vector negation. Creates a new vector which is the negation of this vector. More...
 
float operator* (const Vector3d &v) const
 Computes the dot product of this vector with the given vector. More...
 
Vector3d< Type > operator* (float s) const
 Computes the scalar multiplication of this vector with the given scalar value. More...
 
Vector3d< Type > operator/ (float s) const
 Computes the scalar division of this vector with the given scalar value. More...
 
Vector3d operator+ (const Vector3d &v) const
 Computes the vector sum of this vector with the given vector. More...
 
Vector3d operator- (const Vector3d &v) const
 Computes the vector difference of this vector with the given vector. More...
 
bool operator== (const Vector3d &v) const
 Reports if this vector is the same as the given vector. More...
 
bool operator!= (const Vector3d &v) const
 Reports if this vector is the different from the given vector. More...
 
Vector3doperator*= (float s)
 Perform in-place scalar multiplication on this vector. More...
 
Vector3doperator/= (float s)
 Perform in-place scalar division on this vector. More...
 
Vector3doperator+= (const Vector3d &v)
 Perform in-place vector addition on this vector. More...
 
Vector3doperator-= (const Vector3d &v)
 Perform in-place vector subtraction on this vector. More...
 
void negate ()
 Negate the vector in place.
 
void normalize ()
 Normalize the vector in place.
 
void SumScale (Type s, const Vector3d &v)
 Adds in a scaled version of another vector this += s * v. More...
 
Vector3d rotateX (float angle) const
 Rotate the vector around the x axis. More...
 
Vector3d rotateY (float angle) const
 Rotate the vector around the y axis. More...
 
Vector3d rotateZ (float angle) const
 Rotate the vector around the z axis. More...
 
Vector3d rotateV (Type angle, const Vector3d &v) const
 Rotate the vector around an arbitrary vector. More...
 
void rotateV_ip (Type angle, const Vector3d &v)
 Rotate the vector around an arbitrary vector - change the vector in place. More...
 
Type Length () const
 Compute the magnitude (aka length) of the vector. More...
 
Vector3d cross (const Vector3d< Type > &v)
 Cross product of this vector with the given vector this x v. More...
 
float distance (const Vector3d &p) const
 Compute the distance from this vector to another point. More...
 
float distance (float x, float y, float z) const
 Compute the distance from this vector to another point. More...
 
float distanceSq (const Vector3d &p) const
 Compute the squared-distance from this vector to another point. More...
 
float distanceSq (float x, float y, float z) const
 Compute the squared-distance from this vector to another point. More...
 

Public Attributes

Type _x
 x-component of the vector
 
Type _y
 y-component of the vector
 
Type _z
 z-component of the vector
 

Detailed Description

template<class Type>
class Menge::Math::Vector3d< Type >

Templated vector in R3.

Constructor & Destructor Documentation

template<class Type>
Menge::Math::Vector3d< Type >::Vector3d ( Type  x,
Type  y,
Type  z 
)
inline

Constructor with arguments.

Parameters
xThe vector's x-component.
yThe vector's y-component.
zThe vector's z-component.
template<class Type>
Menge::Math::Vector3d< Type >::Vector3d ( const Vector3d< Type > &  v)
inline

Copy constructor.

Parameters
vThe vector to copy from.

Member Function Documentation

template<class Type>
Vector3d Menge::Math::Vector3d< Type >::cross ( const Vector3d< Type > &  v)
inline

Cross product of this vector with the given vector this x v.

Parameters
vThe second opearand.
Returns
The vector representing the cross product of this with v.
template<class Type>
float Menge::Math::Vector3d< Type >::distance ( const Vector3d< Type > &  p) const
inline

Compute the distance from this vector to another point.

Parameters
pThe point whose distance from this vector (interpreted as a point) is to be computed
Returns
The distance between this vector and p.
template<class Type>
float Menge::Math::Vector3d< Type >::distance ( float  x,
float  y,
float  z 
) const
inline

Compute the distance from this vector to another point.

Parameters
xThe x-value of the other point.
yThe y-value of the other point.
zThe z-value of the other point.
Returns
The distance between this vector and (x, y).
template<class Type>
float Menge::Math::Vector3d< Type >::distanceSq ( const Vector3d< Type > &  p) const
inline

Compute the squared-distance from this vector to another point.

Parameters
pThe point whose distance from this vector (interpreted as a point) is to be computed
Returns
The squared-distance between this vector and p.
template<class Type>
float Menge::Math::Vector3d< Type >::distanceSq ( float  x,
float  y,
float  z 
) const
inline

Compute the squared-distance from this vector to another point.

Parameters
xThe x-value of the other point.
yThe y-value of the other point.
zThe z-value of the other point.
Returns
The squared-distance between this vector and (x, y).
template<class Type>
Type Menge::Math::Vector3d< Type >::Length ( ) const
inline

Compute the magnitude (aka length) of the vector.

Returns
The magnitude of the vector.
template<class Type>
bool Menge::Math::Vector3d< Type >::operator!= ( const Vector3d< Type > &  v) const
inline

Reports if this vector is the different from the given vector.

Parameters
vThe second operand.
Returns
True if the vectors are at all different, false otherwise
template<class Type>
float Menge::Math::Vector3d< Type >::operator* ( const Vector3d< Type > &  v) const
inline

Computes the dot product of this vector with the given vector.

Parameters
vThe with which the dot product should be computed.
Returns
The dot product of this vector with the given vector
template<class Type>
Vector3d<Type> Menge::Math::Vector3d< Type >::operator* ( float  s) const
inline

Computes the scalar multiplication of this vector with the given scalar value.

Parameters
sThe scalar value
Returns
The scalar multiplication of this vector with a specified scalar value.
template<class Type>
Vector3d& Menge::Math::Vector3d< Type >::operator*= ( float  s)
inline

Perform in-place scalar multiplication on this vector.

Parameters
sThe scalar mutliplicand.
Returns
A reference to the vector.
template<class Type>
Vector3d Menge::Math::Vector3d< Type >::operator+ ( const Vector3d< Type > &  v) const
inline

Computes the vector sum of this vector with the given vector.

Parameters
vThe second operand.
Returns
The vector sum of this vector with the given vector.
template<class Type>
Vector3d& Menge::Math::Vector3d< Type >::operator+= ( const Vector3d< Type > &  v)
inline

Perform in-place vector addition on this vector.

Parameters
vThe second vector operand.
Returns
A reference to the vector.
template<class Type>
Vector3d<Type> Menge::Math::Vector3d< Type >::operator- ( ) const
inline

Vector negation. Creates a new vector which is the negation of this vector.

Returns
The vector in the opposite direction of this vector
template<class Type>
Vector3d Menge::Math::Vector3d< Type >::operator- ( const Vector3d< Type > &  v) const
inline

Computes the vector difference of this vector with the given vector.

Parameters
vThe second operand.
Returns
The vector difference of this vector with the given vector.
template<class Type>
Vector3d& Menge::Math::Vector3d< Type >::operator-= ( const Vector3d< Type > &  v)
inline

Perform in-place vector subtraction on this vector.

Parameters
vThe second vector operand.
Returns
A reference to the vector.
template<class Type>
Vector3d<Type> Menge::Math::Vector3d< Type >::operator/ ( float  s) const
inline

Computes the scalar division of this vector with the given scalar value.

Parameters
sThe scalar value
Returns
The scalar division of this vector with a specified scalar value.
template<class Type>
Vector3d& Menge::Math::Vector3d< Type >::operator/= ( float  s)
inline

Perform in-place scalar division on this vector.

Parameters
sThe scalar divisor.
Returns
A reference to the vector.
template<class Type>
bool Menge::Math::Vector3d< Type >::operator== ( const Vector3d< Type > &  v) const
inline

Reports if this vector is the same as the given vector.

Parameters
vThe second operand.
Returns
True if the vectors are exactly identical, False otherwise
template<class Type>
Type Menge::Math::Vector3d< Type >::operator[] ( const int  i) const
inline

Index-style access to vector components.

Parameters
iThe index of the desired component. Sould be in the range [0, 2].
Returns
The ith component of the vector.
template<class Type>
Type& Menge::Math::Vector3d< Type >::operator[] ( const int  i)
inline

Index-style access to vector components as a reference.

Parameters
iThe index of the desired component. Sould be in the range [0, 2].
Returns
A reference to the ith component of the vector.
template<class Type>
Vector3d Menge::Math::Vector3d< Type >::rotateV ( Type  angle,
const Vector3d< Type > &  v 
) const
inline

Rotate the vector around an arbitrary vector.

Parameters
angleThe amoutn of rotations (in radians)
vThe axis of rotation - it should be normalized
Returns
The rotated vector
template<class Type>
void Menge::Math::Vector3d< Type >::rotateV_ip ( Type  angle,
const Vector3d< Type > &  v 
)
inline

Rotate the vector around an arbitrary vector - change the vector in place.

Parameters
angleThe amoutn of rotations (in radians)
vThe axis of rotation - it should be normalized
template<class Type>
Vector3d Menge::Math::Vector3d< Type >::rotateX ( float  angle) const
inline

Rotate the vector around the x axis.

Parameters
angleThe amoutn of rotations (in radians)
Returns
The rotated vector
template<class Type>
Vector3d Menge::Math::Vector3d< Type >::rotateY ( float  angle) const
inline

Rotate the vector around the y axis.

Parameters
angleThe amoutn of rotations (in radians)
Returns
The rotated vector
template<class Type>
Vector3d Menge::Math::Vector3d< Type >::rotateZ ( float  angle) const
inline

Rotate the vector around the z axis.

Parameters
angleThe amoutn of rotations (in radians)
Returns
The rotated vector
template<class Type>
void Menge::Math::Vector3d< Type >::set ( Type  x,
Type  y,
Type  z 
)
inline

Set the x- and y-values from scalar values.

Parameters
xThe value for the x-component
yThe value for the y-component
zThe value for the z-component
template<class Type>
void Menge::Math::Vector3d< Type >::set ( const Vector3d< Type > &  v)
inline

Set the x-, y- and z-values from a vector.

Parameters
vThe vector containing the newvalues
template<class Type>
void Menge::Math::Vector3d< Type >::setX ( Type  x)
inline

Set the x-value.

Parameters
xThe x-value.
template<class Type>
void Menge::Math::Vector3d< Type >::setY ( Type  y)
inline

Set the y-value.

Parameters
yThe y-value.
template<class Type>
void Menge::Math::Vector3d< Type >::setZ ( Type  z)
inline

Set the z-value.

Parameters
zThe z-value.
template<class Type>
void Menge::Math::Vector3d< Type >::SumScale ( Type  s,
const Vector3d< Type > &  v 
)
inline

Adds in a scaled version of another vector this += s * v.

Parameters
sThe scale factor for the vector v
vThe vector to scale
template<class Type>
Type Menge::Math::Vector3d< Type >::x ( ) const
inline

Get the x-value.

Returns
The x-value.
template<class Type>
Type Menge::Math::Vector3d< Type >::y ( ) const
inline

Get the y-value.

Returns
The y-value.
template<class Type>
Type Menge::Math::Vector3d< Type >::z ( ) const
inline

Get the z-value.

Returns
The z-value.

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