WFMath_Vector man page

WFMath::Vector< dim > — A dim dimensional vector.

Synopsis

#include <vector.h>

Public Member Functions

Vector ()
Construct an uninitialized vector.
Vector (const Vector &v)
Construct a copy of a vector.
Vector (const AtlasInType &a)
Construct a vector from an object passed by Atlas.
Vector (const Point< dim > &point)
Construct a vector from a point.
AtlasOutType toAtlas () const
Create an Atlas object from the vector.
void fromAtlas (const AtlasInType &a)
Set the vector's value to that given by an Atlas object.
void setValid (bool valid=true)
make isValid() return true if you've initialized the vector by hand
Vector & zero ()
Zero the components of a vector.
CoordType operator[] (const int i) const
Get the i'th element of the vector.
CoordType & operator[] (const int i)
Get the i'th element of the vector.
CoordType sqrMag () const
The squared magnitude of a vector.
CoordType mag () const
The magnitude of a vector.
Vector & normalize (CoordType norm=1.0)
Normalize a vector.
CoordType sloppyMag () const
An approximation to the magnitude of a vector.
Vector & sloppyNorm (CoordType norm=1.0)
Approximately normalize a vector.
Vector & rotate (int axis1, int axis2, CoordType theta)
Rotate the vector in the (axis1, axis2) plane by the angle theta.
Vector & rotate (const Vector &v1, const Vector &v2, CoordType theta)
Rotate the vector in the (v1, v2) plane by the angle theta.
Vector & rotate (const RotMatrix< dim > &)
Rotate the vector using a matrix.
Vector & mirror (const int i)
Reflect a vector in the direction of the i'th axis.
Vector & mirror (const Vector &v)
Reflect a vector in the direction specified by v.
Vector & mirror ()
Reflect a vector in all directions simultaneously.
Vector (CoordType x, CoordType y)
2D only: construct a vector from (x, y) coordinates
Vector (CoordType x, CoordType y, CoordType z)
3D only: construct a vector from (x, y, z) coordinates
Vector & rotate (CoordType theta)
2D only: rotate a vector by an angle theta
Vector & rotateX (CoordType theta)
3D only: rotate a vector about the x axis by an angle theta
Vector & rotateY (CoordType theta)
3D only: rotate a vector about the y axis by an angle theta
Vector & rotateZ (CoordType theta)
3D only: rotate a vector about the z axis by an angle theta
Vector & rotate (const Vector &axis, CoordType theta)
3D only: rotate a vector about the i'th axis by an angle theta
Vector & rotate (const Quaternion &q)
3D only: rotate a vector using a Quaternion
CoordType x () const
Access the first component of a vector.
CoordType & x ()
Access the first component of a vector.
CoordType y () const
Access the second component of a vector.
CoordType & y ()
Access the second component of a vector.
CoordType z () const
Access the third component of a vector.
CoordType & z ()
Access the third component of a vector.
Vector & mirrorX ()
Flip the x component of a vector.
Vector & mirrorY ()
Flip the y component of a vector.
Vector & mirrorZ ()
Flip the z component of a vector.
Vector & polar (CoordType r, CoordType theta)
2D only: construct a vector from polar coordinates
void asPolar (CoordType &r, CoordType &theta) const
2D only: convert a vector to polar coordinates
Vector & polar (CoordType r, CoordType theta, CoordType z)
3D only: construct a vector from polar coordinates
void asPolar (CoordType &r, CoordType &theta, CoordType &z) const
3D only: convert a vector to polar coordinates
Vector & spherical (CoordType r, CoordType theta, CoordType phi)
3D only: construct a vector from shperical coordinates
void asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const
3D only: convert a vector to shperical coordinates

Static Public Member Functions

static const Vector< dim > & ZERO ()
Provides a global instance preset to zero.
static CoordType sloppyMagMax ()
The maximum ratio of the return value of sloppyMag() to the true magnitude.
static CoordType sloppyMagMaxSqrt ()
The square root of sloppyMagMax()

Friends

Vector & operator+= (Vector &v1, const Vector &v2)
Add the second vector to the first.
Vector & operator-= (Vector &v1, const Vector &v2)
Subtract the second vector from the first.
Vector & operator*= (Vector &v, CoordType d)
Multiply the magnitude of v by d.
Vector & operator/= (Vector &v, CoordType d)
Divide the magnitude of v by d.
Vector operator+ (const Vector &v1, const Vector &v2)
Take the sum of two vectors.
Vector operator- (const Vector &v1, const Vector &v2)
Take the difference of two vectors.
Vector operator- (const Vector &v)
Reverse the direction of a vector.
Vector operator* (CoordType d, const Vector &v)
Multiply a vector by a scalar.
Vector operator* (const Vector &v, CoordType d)
Multiply a vector by a scalar.
Vector operator/ (const Vector &v, CoordType d)
Divide a vector by a scalar.
Vector Prod (const RotMatrix< dim > &m, const Vector &v)
returns m * v
Vector InvProd (const RotMatrix< dim > &m, const Vector &v)
returns m^-1 * v
Vector operator- (const Point< dim > &c1, const Point< dim > &c2)
Find the vector which gives the offset between two points.
Point< dim > operator+ (const Point< dim > &c, const Vector &v)
Find the point at the offset v from the point c.
Point< dim > operator- (const Point< dim > &c, const Vector &v)
Find the point at the offset -v from the point c.
Point< dim > operator+ (const Vector &v, const Point< dim > &c)
Find the point at the offset v from the point c.
Point< dim > & operator+= (Point< dim > &p, const Vector &rhs)
Shift a point by a vector.
Point< dim > & operator-= (Point< dim > &p, const Vector &rhs)
Shift a point by a vector, in the opposite direction.
CoordType Cross (const Vector< 2 > &v1, const Vector< 2 > &v2)
2D only: get the z component of the cross product of two vectors
Vector< 3 > Cross (const Vector< 3 > &v1, const Vector< 3 > &v2)
3D only: get the cross product of two vectors
CoordType Dot (const Vector &v1, const Vector &v2)
The dot product of two vectors.
CoordType Angle (const Vector &v, const Vector &u)
The angle between two vectors.

Detailed Description

template<int dim = 3>

class WFMath::Vector< dim >" A dim dimensional vector.

This class implements the 'generic' subset of the interface in the fake class Shape.

Member Function Documentation

template<int dim = 3> Vector& WFMath::Vector< dim >::mirror () [inline]

Reflect a vector in all directions simultaneously. This is a nice way to implement the parity operation if dim is odd.

Referenced by WFMath::Vector< 3 >::mirrorX(), and WFMath::Vector< 3 >::mirrorY().

template<int dim> Vector< dim > & WFMath::Vector< dim >::rotate (const Vector< dim > & v1, const Vector< dim > & v2, CoordType theta)

Rotate the vector in the (v1, v2) plane by the angle theta. This throws CollinearVectors if v1 and v2 are parallel.

References WFMath::Vector< dim >::Prod, and WFMath::RotMatrix< dim >::rotation().

template<int dim = 3> CoordType WFMath::Vector< dim >::sloppyMag () const

An approximation to the magnitude of a vector. The sloppyMag() function gives a value between the true magnitude and sloppyMagMax multiplied by the true magnitude. sloppyNorm() uses sloppyMag() to normalize the vector. This is currently only implemented for dim = {1, 2, 3}. For all current implementations, sloppyMagMax is greater than or equal to one. The constant sloppyMagMaxSqrt is provided for those who want to most closely approximate the true magnitude, without caring whether it's too low or too high.

Referenced by WFMath::Vector< 3 >::normalize(), WFMath::Perpendicular(), and WFMath::Vector< dim >::sloppyNorm().

template<int dim = 3> static CoordType WFMath::Vector< dim >::sloppyMagMaxSqrt () [static]

The square root of sloppyMagMax() This is provided for people who want to obtain maximum accuracy from sloppyMag(), without caring whether the answer is high or low. The result sloppyMag()/sloppyMagMaxSqrt() will be within sloppyMagMaxSqrt() of the true magnitude.

Referenced by WFMath::Vector< 3 >::normalize(), and WFMath::Parallel().

template<int dim> Vector< dim > & WFMath::Vector< dim >::sloppyNorm (CoordType norm = 1.0)

Approximately normalize a vector. Normalize a vector using sloppyMag() instead of the true magnitude. The new length of the vector will be between norm/sloppyMagMax() and norm.

References WFMath::Vector< dim >::mag(), and WFMath::Vector< dim >::sloppyMag().

Referenced by WFMath::Vector< 3 >::normalize().

Author

Generated automatically by Doxygen for WFMath from the source code.

Info

Fri Feb 5 2016 Version 1.0.2 WFMath