#include <vector3.h>
Public Member Functions |
|
Constructors and Destructors
|
|
TVector3 () | |
Default constructor. |
|
TVector3 (const T *ptr) throw (Exception::NullPointer) | |
Array constructor. |
|
TVector3 (const T &value) | |
Scalar constructor. |
|
TVector3 (const T &vx, const T &vy, const T &vz) | |
Detailed constructor. |
|
TVector3 (const TVector3 &vector) | |
Copy constructor. |
|
TVector3 (const T &r, const TAngle< T > &phi, const TAngle< T > &theta) | |
Spherical polar coordinate
constructor. |
|
~TVector3 () | |
Destructor. |
|
void | clear () |
Clear method The values are set to
0. |
|
Arithmetic operators
|
|
const TVector3 & | operator+ () const |
Positive sign. |
|
TVector3 | operator- () const |
Negative sign. |
|
TVector3 | operator+ (const TVector3 &b) const |
Addition. |
|
TVector3 | operator- (const TVector3 &b) const |
Subtraction. |
|
TVector3 & | operator+= (const TVector3 &vector) |
Add a vector to this vector.
|
|
TVector3 & | operator-= (const TVector3 &vector) |
Subtract a vector from this vector.
|
|
TVector3 | operator* (const T &scalar) const |
Scalar product. |
|
TVector3 & | operator*= (const T &scalar) |
Multiply by a scalar. |
|
TVector3 | operator/ (const T &lambda) const throw (Exception::DivisionByZero) |
Fraction of a vector. |
|
TVector3 & | operator/= (const T &lambda) throw (Exception::DivisionByZero) |
Divide a vector by a scalar.
|
|
T | operator* (const TVector3 &vector) const |
Dot product. |
|
TVector3 | operator% (const TVector3 &vector) const |
Cross product. |
|
TVector3 & | operator%= (const TVector3 &vector) |
Assign to the cross product.
|
|
Predicates
|
|
bool | operator== (const TVector3 &vector) const |
Equality operator. |
|
bool | operator!= (const TVector3 &vector) const |
Inequality operator. |
|
bool | operator< (const TVector3 &vector) const |
Needed for MSVC. |
|
bool | isZero () const |
Zero predicate. |
|
bool | isOrthogonalTo (const TVector3 &vector) const |
Orthogonality predicate. |
|
Storable Interface
|
|
void | write (PersistenceManager &pm) const |
Persistent stream
writing. |
|
bool | read (PersistenceManager &pm) |
Persistent stream
reading. |
|
Debugging and Diagnostics
|
|
void | dump (std::ostream &s=std::cout, Size depth=0) const |
Internal state dump. |
|
bool | isValid () const |
Test if instance is valid. |
|
Public Attributes |
|
Vector components
|
|
For easier access, the three components of the vector
are public members.
|
|
T | x |
x component of the vector |
|
T | y |
y component of the vector |
|
T | z |
z component of the vector |
|
Assignment |
|
void | set (const T *ptr) throw (Exception::NullPointer) |
Assign from an array. |
|
void | set (const T &value) |
Assign from a scalar. |
|
void | set (const T &vx, const T &vy, const T &vz) |
Assign the vector components.
|
|
void | set (const TVector3 &vector) |
Assign from another TVector3. |
|
void | set (const T &r, const TAngle< T > &phi, const TAngle< T > &theta) |
Assign from spherical polar
coordinates. |
|
TVector3 & | operator= (const TVector3 &v) |
Assignment operator. |
|
TVector3 & | operator= (T value) |
Assignment operator. |
|
TVector3 & | operator= (const T *ptr) throw (Exception::NullPointer) |
Array assignment operator. |
|
void | get (T *ptr) const throw (Exception::NullPointer) |
Assign to an array. |
|
void | get (T &x, T &y, T &z) const |
Assign to three variables of type
T . |
|
void | get (TVector3 &vector) const |
Assign to another Vector3. |
|
void | get (T &r, TAngle< T > &phi, TAngle< T > &theta) const |
Assign to polar coordinates.
|
|
void | swap (TVector3 &vector) |
Swap the contents of two vectors.
|
|
T | getLength () const |
Return the length of the vector.
|
|
T | getSquareLength () const |
Return the squared length of the
vector. |
|
TVector3 & | normalize () throw (Exception::DivisionByZero) |
Normalize the vector. |
|
TVector3 & | negate () |
Negate the vector. |
|
T & | operator[] (Position position) throw (Exception::IndexOverflow) |
Mutable array-like access to the
components. |
|
const T & | operator[] (Position position) const throw (Exception::IndexOverflow) |
Constant
array-like access to the components. |
|
static const TVector3 & | getZero () |
Return a vector with all components
0. |
|
static const TVector3 & | getUnit () |
Return a vector with all components
1. |
|
Geometric properties |
|
T | getDistance (const TVector3 &vector) const |
Return the distance to another
vector. |
|
T | getSquareDistance (const TVector3 &vector) const |
Return the squared distance to
another vector. |
|
TAngle< T > | getAngle (const TVector3 &vector) const throw (Exception::DivisionByZero) |
Return the enclosed angle of two
vectors. |
|
TVector3 | getOrthogonalProjection (const TVector3 &direction) const |
Return the orthogonal projection of
this vector onto another. |
|
static TVector3 | getPerpendicularNormalization (const TVector3 &a, const TVector3 &b, const TVector3 &c) |
Return the perpendicular
normalization of the vector. |
|
static T | getTripleProduct (const TVector3< T > &a, const TVector3< T > &b, const TVector3< T > &c) |
Triple
product of three vectors. |
BALL::TVector3< T >::TVector3 | ( | ) |
Default constructor.
This method creates a new TVector3 object.
The three components are initialized to
(T)0
.
Referenced by BALL::TVector3< T >::operator%().
BALL::TVector3< T >::TVector3 | ( | const T * | ptr | ) | throw (Exception::NullPointer) |
Array constructor.
This constructor creates a TVector3 object
from the first three elements pointed to by
ptr
.
ptr | the array to construct from |
NullPointer | if ptr == 0 |
BALL::TVector3< T >::TVector3 | ( | const T & | value | ) | [explicit] |
Scalar constructor.
Create a new vector with all components set to the same
value
.
value | the value of all components |
BALL::TVector3< T >::TVector3 | ( | const T & | vx, | |
const T & | vy, | |||
const T & | vz | |||
) |
Detailed constructor.
Create a new TVector3 object
from three variables of type T
.
vx | assigned to x |
|
vy | assigned to y |
|
vz | assigned to z |
BALL::TVector3< T >::TVector3 | ( | const TVector3< T > & | vector | ) |
BALL::TVector3< T >::TVector3 | ( | const T & | r, | |
const TAngle< T > & | phi, | |||
const TAngle< T > & | theta | |||
) |
Spherical polar coordinate constructor.
Create a TVector3
object and set its coordinates to the point described by
the three spherical polar coordinates r
(radius), phi
(azimuth), and
theta
(co-latitude).
r | the radius | |
phi | the azimuth | |
theta | the co-latitude |
BALL::TVector3< T >::~TVector3 | ( | ) |
Destructor.
Destructs the TVector3 object. As there are no dynamic data structures, nothing happens.
void BALL::TVector3< T >::dump | ( | std::ostream & | s =
std::cout , |
|
Size | depth =
0 |
|||
) | const |
Internal state dump.
Dump the current internal state of {*this} to the output ostream s with dumping depth depth .
s | - output stream where to output the internal state of {*this} | |
depth | - the dumping depth |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::get | ( | T & | r, | |
TAngle< T > & | phi, | |||
TAngle< T > & | theta | |||
) | const |
Assign to polar coordinates.
Sets r
, phi
, and
theta
to the coordinates of the vector in
spherical polar coordinates.
r | the radius (returned) | |
phi | the azimuth (returned) | |
theta | the co-latitude (returned) |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::get | ( | TVector3< T > & | vector | ) | const |
Assign to another Vector3.
Assigns the vector components to another vector.
vector | the vector to be assigned to |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::get | ( | T & | x, | |
T & | y, | |||
T & | z | |||
) | const |
Assign to three variables of type T
.
x | the x component | |
y | the y component | |
z | the z component |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::get | ( | T * | ptr | ) | const throw (Exception::NullPointer) |
Assign to an array.
Sets the first three array elements pointed to by
ptr
to the values of the three vector
components.
ptr | the array |
NullPointer | if ptr == 0 |
TAngle< T > BALL::TVector3< T >::getAngle | ( | const TVector3< T > & | vector | ) | const throw (Exception::DivisionByZero) |
Return the enclosed angle of two vectors.
Exception::DivisionByZero | if the product of the squared lengths of the
two vectors equals (T)0 |
Referenced by BALL::GetAngle().
T BALL::TVector3< T >::getLength | ( | ) | const |
Return the length of the vector.
The length of the vector is calculated as .
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
Referenced by BALL::TQuaternion< T >::fromAxisAngle().
TVector3< T > BALL::TVector3< T >::getOrthogonalProjection | ( | const TVector3< T > & | direction | ) | const |
Return the orthogonal projection of this vector onto another.
direction | the vector to project onto |
TVector3< T > BALL::TVector3< T >::getPerpendicularNormalization | ( | const TVector3< T > & | a, | |
const TVector3< T > & | b, | |||
const TVector3< T > & | c | |||
) | [static] |
Return the perpendicular normalization of the vector.
a | 1st vector | |
b | 2nd vector | |
c | 3rd vector |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
T BALL::TVector3< T >::getSquareLength | ( | ) | const |
Return the squared length of the vector.
This method avoids the square root needed in getLength, so this method is preferred if possible.
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
Referenced by BALL::GetAngle().
T BALL::TVector3< T >::getTripleProduct | ( | const TVector3< T > & | a, | |
const TVector3< T > & | b, | |||
const TVector3< T > & | c | |||
) | [static] |
Triple product of three vectors.
Calculate the parallelepipedal product of three vectors.
a | first vector | |
b | second vector | |
v | third vector |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
Referenced by BALL::GetDistance().
const TVector3< T > & BALL::TVector3< T >::getUnit | ( | ) | [static] |
Return a vector with all components 1.
bool BALL::TVector3< T >::isValid | ( | ) | const |
Test if instance is valid.
Always returns true.
bool BALL::TVector3< T >::isZero | ( | ) | const |
Zero predicate.
The function Maths::isZero is used to compare the values with zero. Maths::isZero
References BALL::Maths::isZero(), BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
Referenced by BALL::TVector3< T >::isOrthogonalTo().
TVector3< T > & BALL::TVector3< T >::negate | ( | ) |
Negate the vector.
Negate the three components of the vector
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > & BALL::TVector3< T >::normalize | ( | ) | throw (Exception::DivisionByZero) |
Normalize the vector.
The vector is scaled with its length: .
DivisionByZero | if the length of the vector is 0 |
References BALL::Maths::isZero(), BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
Referenced by BALL::GetIntersection(), and BALL::VIEW::Camera::moveForward().
bool BALL::TVector3< T >::operator!= | ( | const TVector3< T > & | vector | ) | const |
Inequality operator.
The function Maths::isEqual is used to compare the values. Maths::isEqual
References BALL::Maths::isNotEqual(), BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > BALL::TVector3< T >::operator% | ( | const TVector3< T > & | vector | ) | const |
Cross product.
Return the cross product of this vector and
vector
.
References BALL::TVector3< T >::TVector3(), BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > & BALL::TVector3< T >::operator%= | ( | const TVector3< T > & | vector | ) |
Assign to the cross product.
Assign the vector to its cross product with another vector.
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
T BALL::TVector3< T >::operator* | ( | const TVector3< T > & | vector | ) | const |
Dot product.
Return the dot product of this vector and
vector
.
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > BALL::TVector3< T >::operator* | ( | const T & | scalar | ) | const |
Scalar product.
Return TVector3(x * scalar, y * scalar, z *
scalar)
.
scalar,the | scalar to multiply by |
scalar
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > & BALL::TVector3< T >::operator*= | ( | const T & | scalar | ) |
Multiply by a scalar.
Multiply all components of the vector by a
scalar
value.
scalar | the to multiply by |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > & BALL::TVector3< T >::operator+= | ( | const TVector3< T > & | vector | ) |
Add a vector to this vector.
Add the components of vector
to this
vector.
vector | the vector to add |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > & BALL::TVector3< T >::operator-= | ( | const TVector3< T > & | vector | ) |
Subtract a vector from this vector.
vector | the vector to subtract |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > BALL::TVector3< T >::operator/ | ( | const T & | lambda | ) | const throw (Exception::DivisionByZero) |
Fraction of a vector.
Return TVector3(x /
lambda, y / lambda, z / lambda)
.
lambda | the scalar value to divide by |
Exception::DivisionByZero | if lambda == (T)0 |
TVector3< T > & BALL::TVector3< T >::operator/= | ( | const T & | lambda | ) | throw (Exception::DivisionByZero) |
Divide a vector by a scalar.
lambda | the scalar value to divide by |
Exception::DivisionByZero | if lambda == (T)0 |
TVector3< T > & BALL::TVector3< T >::operator= | ( | const T * | ptr | ) | throw (Exception::NullPointer) |
Array assignment operator.
Assigns the first three elements of an array to the vector components.
ptr | the array |
NullPointer | if ptr == 0 |
TVector3< T > & BALL::TVector3< T >::operator= | ( | T | value | ) |
Assignment operator.
Assign a constant value to all three vector components.
value | the constant to assign to x, y, z |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
TVector3< T > & BALL::TVector3< T >::operator= | ( | const TVector3< T > & | v | ) |
Assignment operator.
Assign the vector components from another vector.
v | the vector to assign from |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
bool BALL::TVector3< T >::operator== | ( | const TVector3< T > & | vector | ) | const |
Equality operator.
The function Maths::isEqual is used to compare the values. Maths::isEqual
References BALL::Maths::isEqual(), BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
const T & BALL::TVector3< T >::operator[] | ( | Position | position | ) | const throw (Exception::IndexOverflow) |
Constant array-like access to the components.
Exception::IndexOverflow | if index > 2 |
T & BALL::TVector3< T >::operator[] | ( | Position | position | ) | throw (Exception::IndexOverflow) |
Mutable array-like access to the components.
Exception::IndexOverflow | if index > 2 |
void BALL::TVector3< T >::set | ( | const T & | r, | |
const TAngle< T > & | phi, | |||
const TAngle< T > & | theta | |||
) |
Assign from spherical polar coordinates.
The radius describes the distance of the point from the origin.
phi
ranges from 0 to ,
theta
ranges from 0 (north pole, positive
z-axis) to (south pole, negative z-axis).r | the radius | |
phi | the azimuth | |
theta | the co-latitude |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::set | ( | const TVector3< T > & | vector | ) |
Assign from another TVector3.
vector | the TVector3 object to assign from |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::set | ( | const T & | vx, | |
const T & | vy, | |||
const T & | vz | |||
) |
Assign the vector components.
vx | the new x component | |
vy | the new y component | |
vz | the new z component |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::set | ( | const T & | value | ) |
Assign from a scalar.
Assign value
to the three vector
components.
value | the new value of the components |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.
void BALL::TVector3< T >::set | ( | const T * | ptr | ) | throw (Exception::NullPointer) |
Assign from an array.
Assign the three components x
,
y
, and z
from the first three
elements of the array pointed to by ptr
.
ptr | an array |
Nullpointer | if ptr == 0 |
Referenced by BALL::TRegularData3D< ValueType >::clear(), BALL::TSimpleBox3< T >::get(), BALL::TFFT3D< ComplexTraits >::getGridCoordinates(), BALL::GetIntersection(), and BALL::HashGrid3< Item >::set().
void BALL::TVector3< T >::swap | ( | TVector3< T > & | vector | ) |
Swap the contents of two vectors.
vector | the vector to swap contents with |
References BALL::TVector3< T >::x, BALL::TVector3< T >::y, and BALL::TVector3< T >::z.