mesh::Vector3 Class Reference

#include <vector3.h>

Collaboration diagram for mesh::Vector3:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Vector3 ()
 Vector3 (Real fX, Real fY, Real fZ)
 Vector3 (Real afCoordinate[3])
 Vector3 (int afCoordinate[3])
 Vector3 (const Real *const r)
 Vector3 (const Vector3 &rkVector)
Real operator[] (unsigned i) const
Real & operator[] (unsigned i)
Vector3operator= (const Vector3 &rkVector)
bool operator== (const Vector3 &rkVector) const
bool operator!= (const Vector3 &rkVector) const
Vector3 operator+ (const Vector3 &rkVector) const
Vector3 operator- (const Vector3 &rkVector) const
Vector3 operator * (Real fScalar) const
Vector3 operator * (const Vector3 &rhs) const
Vector3 operator/ (Real fScalar) const
Vector3 operator- () const
Vector3operator+= (const Vector3 &rkVector)
Vector3operator-= (Real fScalar)
Vector3operator-= (const Vector3 &rkVector)
Vector3operator *= (Real fScalar)
Vector3operator *= (const Vector3 &rkVector)
Vector3operator/= (Real fScalar)
Real length () const
Real squared_length () const
Real dot_product (const Vector3 &vec) const
Real normalise ()
Vector3 cross_product (const Vector3 &rkVector) const
Vector3 mid_point (const Vector3 &vec) const
bool operator< (const Vector3 &rhs) const
bool operator<= (const Vector3 &rhs) const
bool operator< (Real scalar) const
bool operator<= (Real scalar) const
bool operator> (const Vector3 &rhs) const
bool operator> (Real scalar) const
bool operator>= (Real scalar) const
void make_floor (const Vector3 &cmp)
void make_ceil (const Vector3 &cmp)
Vector3 perpendicular (void) const
bool is_zero_length (void) const
Vector3 normalised_copy (void) const
Vector3 reflect (const Vector3 &normal)

Public Attributes

Real x
Real y
Real z

Static Public Attributes

static const Vector3 ZERO
static const Vector3 UNIT_X
static const Vector3 UNIT_Y
static const Vector3 UNIT_Z
static const Vector3 UNIT_SCALE

Friends

Vector3 operator * (Real fScalar, const Vector3 &rkVector)
std::ostream & operator<< (std::ostream &o, const Vector3 &v)

Detailed Description

Standard 3-dimensional vector.
Remarks:
A direction in 3D space represented as distances along the 3 orthoganal axes (x, y, z). Note that positions, directions and scaling factors can be represented by a vector, depending on how you interpret the values.

Definition at line 35 of file vector3.h.


Constructor & Destructor Documentation

mesh::Vector3::Vector3 (  )  [inline]

Definition at line 41 of file vector3.h.

Referenced by mid_point(), and reflect().

mesh::Vector3::Vector3 ( Real  fX,
Real  fY,
Real  fZ 
) [inline]

Definition at line 45 of file vector3.h.

mesh::Vector3::Vector3 ( Real  afCoordinate[3]  )  [inline]

Definition at line 50 of file vector3.h.

mesh::Vector3::Vector3 ( int  afCoordinate[3]  )  [inline]

Definition at line 57 of file vector3.h.

References Real, x, y, and z.

mesh::Vector3::Vector3 ( const Real *const   r  )  [inline]

Definition at line 64 of file vector3.h.

mesh::Vector3::Vector3 ( const Vector3 rkVector  )  [inline]

Definition at line 69 of file vector3.h.


Member Function Documentation

Vector3 mesh::Vector3::cross_product ( const Vector3 rkVector  )  const [inline]

Calculates the cross-product of 2 vectors, i.e. the vector that lies perpendicular to them both.

Remarks:
The cross-product is normally used to calculate the normal vector of a plane, by calculating the cross-product of 2 non-equivalent vectors which lie on the plane (e.g. 2 edges of a triangle).
Parameters:
vec Vector which, together with this one, will be used to calculate the cross-product.
Returns:
A vector which is the result of the cross-product. This vector will NOT be normalised, to maximise efficiency
  • call Vector3::normalise on the result if you wish this to be done. As for which side the resultant vector will be on, the returned vector will be on the side from which the arc from 'this' to rkVector is anticlockwise, e.g. UNIT_Y.crossProduct(UNIT_Z) = UNIT_X, whilst UNIT_Z.crossProduct(UNIT_Y) = -UNIT_X.
For a clearer explanation, look a the left and the bottom edges of your monitor's screen. Assume that the first vector is the left edge and the second vector is the bottom edge, both of them starting from the lower-left corner of the screen. The resulting vector is going to be perpendicular to both of them and will go inside the screen, towards the cathode tube (assuming you're using a CRT monitor, of course).

Definition at line 339 of file vector3.h.

References x, y, and z.

Referenced by perpendicular().

Real mesh::Vector3::dot_product ( const Vector3 vec  )  const [inline]

Calculates the dot (scalar) product of this vector with another.

Remarks:
The dot product can be used to calculate the angle between 2 vectors. If both are unit vectors, the dot product is the cosine of the angle; otherwise the dot product must be divided by the product of the lengths of both vectors to get the cosine of the angle. This result can further be used to calculate the distance of a point from a plane.
Parameters:
vec Vector with which to calculate the dot product (together with this one).
Returns:
A float representing the dot product value.

Definition at line 282 of file vector3.h.

References x, y, and z.

Referenced by MyEfieldDs< Curve >::operator()(), EfieldIntegrand::operator()(), EfieldDs< Curve >::operator()(), and NedelecElement::surface_integral_curl().

bool mesh::Vector3::is_zero_length ( void   )  const [inline]

Returns true if this vector is zero length.

Definition at line 483 of file vector3.h.

References Real, x, y, and z.

Referenced by perpendicular().

Real mesh::Vector3::length (  )  const [inline]

Returns the length (magnitude) of the vector.

Warning:
This operation requires a square root and is expensive in terms of CPU operations. If you don't need to know the exact length (e.g. for just comparing lengths) use squaredLength() instead.

Definition at line 248 of file vector3.h.

References x, y, and z.

Referenced by postprocess::VtkExport::integrate_a_to_b(), and normalise().

void mesh::Vector3::make_ceil ( const Vector3 cmp  )  [inline]

Sets this vector's components to the maximum of its own and the ones of the passed in vector.

Remarks:
'Maximum' in this case means the combination of the highest value of x, y and z from both vectors. Highest is taken just numerically, not magnitude, so 1 > -3.

Definition at line 452 of file vector3.h.

References x, y, and z.

void mesh::Vector3::make_floor ( const Vector3 cmp  )  [inline]

Sets this vector's components to the minimum of its own and the ones of the passed in vector.

Remarks:
'Minimum' in this case means the combination of the lowest value of x, y and z from both vectors. Lowest is taken just numerically, not magnitude, so -1 < 0.

Definition at line 438 of file vector3.h.

References x, y, and z.

Referenced by mesh::TetMesh::get_bounding_box(), and mesh::Tet::get_bounding_box().

Vector3 mesh::Vector3::mid_point ( const Vector3 vec  )  const [inline]

Returns a vector at a point half way between this and the passed in vector.

Definition at line 353 of file vector3.h.

References Vector3(), x, y, and z.

Here is the call graph for this function:

Real mesh::Vector3::normalise (  )  [inline]

Normalises the vector.

Remarks:
This method normalises the vector such that it's length / magnitude is 1. The result is called a unit vector.
Note:
This function will not crash for zero-sized vectors, but there will be no changes made to their components.
Returns:
The previous length of the vector.

Definition at line 296 of file vector3.h.

References length(), Real, x, y, and z.

Referenced by normalised_copy().

Here is the call graph for this function:

Vector3 mesh::Vector3::normalised_copy ( void   )  const [inline]

As normalise, except that this vector is unaffected and the normalised vector is returned as a copy.

Definition at line 492 of file vector3.h.

References normalise().

Here is the call graph for this function:

Vector3 mesh::Vector3::operator * ( const Vector3 rhs  )  const [inline]

Definition at line 141 of file vector3.h.

References x, y, and z.

Vector3 mesh::Vector3::operator * ( Real  fScalar  )  const [inline]

Definition at line 130 of file vector3.h.

References x, y, and z.

Vector3& mesh::Vector3::operator *= ( const Vector3 rkVector  )  [inline]

Definition at line 222 of file vector3.h.

References x, y, and z.

Vector3& mesh::Vector3::operator *= ( Real  fScalar  )  [inline]

Definition at line 214 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator!= ( const Vector3 rkVector  )  const [inline]

Definition at line 102 of file vector3.h.

References x, y, and z.

Vector3 mesh::Vector3::operator+ ( const Vector3 rkVector  )  const [inline]

Definition at line 108 of file vector3.h.

References x, y, and z.

Vector3& mesh::Vector3::operator+= ( const Vector3 rkVector  )  [inline]

Definition at line 187 of file vector3.h.

References x, y, and z.

Vector3 mesh::Vector3::operator- (  )  const [inline]

Definition at line 164 of file vector3.h.

References x, y, and z.

Vector3 mesh::Vector3::operator- ( const Vector3 rkVector  )  const [inline]

Definition at line 119 of file vector3.h.

References x, y, and z.

Vector3& mesh::Vector3::operator-= ( const Vector3 rkVector  )  [inline]

Definition at line 205 of file vector3.h.

References x, y, and z.

Vector3& mesh::Vector3::operator-= ( Real  fScalar  )  [inline]

Definition at line 196 of file vector3.h.

References x, y, and z.

Vector3 mesh::Vector3::operator/ ( Real  fScalar  )  const [inline]

Definition at line 152 of file vector3.h.

References Real, x, y, and z.

Vector3& mesh::Vector3::operator/= ( Real  fScalar  )  [inline]

Definition at line 230 of file vector3.h.

References Real, x, y, and z.

bool mesh::Vector3::operator< ( Real  scalar  )  const [inline]

Returns true if the vector's components are all smaller than scalar.

Definition at line 384 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator< ( const Vector3 rhs  )  const [inline]

Returns true if the vector's scalar components are all smaller than the ones of the vector it is compared against.

Definition at line 364 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator<= ( Real  scalar  )  const [inline]

Returns true if the vector's components are all smaller or equal than scalar.

Definition at line 394 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator<= ( const Vector3 rhs  )  const [inline]

Returns true if the vector's scalar components are all "<=" than the ones of the vector it is compared against.

Definition at line 374 of file vector3.h.

References x, y, and z.

Vector3& mesh::Vector3::operator= ( const Vector3 rkVector  )  [inline]

Assigns the value of the other vector.

Parameters:
rkVector The other vector

Definition at line 88 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator== ( const Vector3 rkVector  )  const [inline]

Definition at line 97 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator> ( Real  scalar  )  const [inline]

Returns true if the vector's components are all smaller than scalar.

Definition at line 414 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator> ( const Vector3 rhs  )  const [inline]

Returns true if the vector's scalar components are all smaller that the ones of the vector it is compared against.

Definition at line 404 of file vector3.h.

References x, y, and z.

bool mesh::Vector3::operator>= ( Real  scalar  )  const [inline]

Returns true if the vector's components are all smaller or equal than scalar.

Definition at line 424 of file vector3.h.

References x, y, and z.

Real& mesh::Vector3::operator[] ( unsigned  i  )  [inline]

Definition at line 79 of file vector3.h.

References x.

Real mesh::Vector3::operator[] ( unsigned  i  )  const [inline]

Definition at line 74 of file vector3.h.

References x.

Vector3 mesh::Vector3::perpendicular ( void   )  const [inline]

Generates a vector perpendicular to this vector (eg an 'up' vector).

Remarks:
This method will return a vector which is perpendicular to this vector. There are an infinite number of possibilities but this method will guarantee to generate one of them. If you need more control you should use the Quaternion class.

Definition at line 466 of file vector3.h.

References cross_product(), is_zero_length(), UNIT_X, and UNIT_Y.

Here is the call graph for this function:

Vector3 mesh::Vector3::reflect ( const Vector3 normal  )  [inline]

Calculates a reflection vector to the plane with the given normal .

Remarks:
NB assumes 'this' is pointing AWAY FROM the plane, invert if it is not.

Definition at line 502 of file vector3.h.

References Vector3().

Here is the call graph for this function:

Real mesh::Vector3::squared_length (  )  const [inline]

Returns the square of the length(magnitude) of the vector.

Remarks:
This method is for efficiency - calculating the actual length of a vector requires a square root, which is expensive in terms of the operations required. This method returns the square of the length of the vector, i.e. the same as the length but before the square root is taken. Use this if you want to find the longest / shortest vector without incurring the square root.

Definition at line 263 of file vector3.h.

References x, y, and z.


Friends And Related Function Documentation

Vector3 operator * ( Real  fScalar,
const Vector3 rkVector 
) [friend]

Definition at line 175 of file vector3.h.

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

Function for writing to a stream.

Definition at line 517 of file vector3.h.


Member Data Documentation

const Vector3 mesh::Vector3::UNIT_SCALE [static]

Definition at line 512 of file vector3.h.

const Vector3 mesh::Vector3::UNIT_X [static]

Definition at line 509 of file vector3.h.

Referenced by perpendicular().

const Vector3 mesh::Vector3::UNIT_Y [static]

Definition at line 510 of file vector3.h.

Referenced by perpendicular().

const Vector3 mesh::Vector3::UNIT_Z [static]

Definition at line 511 of file vector3.h.

Real mesh::Vector3::x

Definition at line 38 of file vector3.h.

Referenced by mesh::LooseOctree< NodeType >::add_node(), mesh::Tet::cartesian_to_simplex(), mesh::TetMesh::construct_octree(), cross_product(), dot_product(), mesh::Octant< NodeType >::dump(), postprocess::VtkExport::export_a_to_b(), postprocess::VtkExport::export_eigenfields2(), postprocess::VtkExport::export_mesh(), export_mesh(), mesh::LooseOctree< NodeType >::export_vtk_level(), NedelecElement::get_AeMe(), mesh::Octant< NodeType >::get_child_index_for_point(), postprocess::VtkExport::getdimensions(), h5_write_eigenfield(), mesh::Tet::is_inside_bounding_box(), mesh::Tet::is_inside_bounding_box_gracious(), is_zero_length(), length(), make_ceil(), make_floor(), mid_point(), normalise(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<(), operator<=(), mesh::Vector4::operator=(), operator=(), operator==(), operator>(), operator>=(), operator[](), squared_length(), Vector3(), and vtk_export_eigenfields().

Real mesh::Vector3::y

Definition at line 38 of file vector3.h.

Referenced by mesh::LooseOctree< NodeType >::add_node(), mesh::Tet::cartesian_to_simplex(), mesh::TetMesh::construct_octree(), cross_product(), dot_product(), mesh::Octant< NodeType >::dump(), postprocess::VtkExport::export_a_to_b(), postprocess::VtkExport::export_eigenfields2(), postprocess::VtkExport::export_mesh(), export_mesh(), mesh::LooseOctree< NodeType >::export_vtk_level(), NedelecElement::get_AeMe(), mesh::Octant< NodeType >::get_child_index_for_point(), postprocess::VtkExport::getdimensions(), h5_write_eigenfield(), mesh::Tet::is_inside_bounding_box(), mesh::Tet::is_inside_bounding_box_gracious(), is_zero_length(), length(), make_ceil(), make_floor(), mid_point(), normalise(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<(), operator<=(), mesh::Vector4::operator=(), operator=(), operator==(), operator>(), operator>=(), squared_length(), Vector3(), and vtk_export_eigenfields().

Real mesh::Vector3::z

Definition at line 38 of file vector3.h.

Referenced by mesh::LooseOctree< NodeType >::add_node(), mesh::Tet::cartesian_to_simplex(), mesh::TetMesh::construct_octree(), cross_product(), dot_product(), mesh::Octant< NodeType >::dump(), postprocess::VtkExport::export_a_to_b(), postprocess::VtkExport::export_eigenfields2(), postprocess::VtkExport::export_mesh(), export_mesh(), mesh::LooseOctree< NodeType >::export_vtk_level(), NedelecElement::get_AeMe(), mesh::Octant< NodeType >::get_child_index_for_point(), postprocess::VtkExport::getdimensions(), h5_write_eigenfield(), mesh::Tet::is_inside_bounding_box(), mesh::Tet::is_inside_bounding_box_gracious(), is_zero_length(), length(), make_ceil(), make_floor(), mid_point(), normalise(), operator *(), operator *=(), operator!=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<(), operator<=(), mesh::Vector4::operator=(), operator=(), operator==(), operator>(), operator>=(), squared_length(), Vector3(), and vtk_export_eigenfields().

const Vector3 mesh::Vector3::ZERO [static]

Definition at line 508 of file vector3.h.

Referenced by postprocess::LinearFieldInterpolation::eval(), and postprocess::LinearFieldInterpolation::eval_curl().


The documentation for this class was generated from the following files:
Generated on Fri Oct 26 13:35:18 2007 for FEMAXX (Finite Element Maxwell Eigensolver) by  doxygen 1.4.7