Home

SPAvector Class Reference
[Geometric Atoms]

Represents a displacement vector in 3D Cartesian space. More...

#include <vector.hxx>

Inheritance diagram for SPAvector:

Inheritance graph
[legend]

List of all members.

Public Member Functions

double & component (int i)
 Extracts the ith component of a vector and allows it to be modified.
double component (int i) const
 Returns a copy of the ith component of a vector.
void debug (FILE *fp=debug_file_ptr) const
 Outputs debug information to the screen or to the specified file.
void debug_str (char *str) const
 Concatenates the debug information to the passed string.
logical is_zero (const double tol=SPAresabs) const
 Returns TRUE if the length of the SPAvector is less than the given tolerance.
double len () const
 Returns the length of the vector.
double len_sq () const
 Returns the length squared, ( x*x + y*y + z*z ).
SPAvector make_ortho ()
 Returns a SPAvector orthogonal to this SPAvector.
double max_norm (int &i) const
 This method returns the maximum of the fabs of each component, and tells which component was the maximum.
double numerically_stable_len () const
 Not appropriate for general use.
SPAvector const & operator*= (SPAtransf const &t)
 Transforms this vector by an affine transformation.
SPAvector const & operator*= (SPAmatrix const &m)
 Transforms this vector by a 3 X 3 matrix.
SPAvector const & operator*= (double d)
 Multiplication of a vector by a scalar.
SPAvector const & operator+= (SPAvector const &v)
 Adds two vectors.
SPAvector const & operator-= (SPAvector const &v)
 Binary minus operation.
SPAvector const & operator/= (double d)
 Division of a vector by a scalar.
SPAunit_vector orthogonal () const
 Returns a unit vector that is orthogonal to the given vector.
void set_component (int i, double new_c)
 Sets the value of ith component of a vector.
void set_x (double new_x)
 Sets the x-coordinate of a vector.
void set_y (double new_y)
 Sets the y-coordinate of a vector.
void set_z (double new_z)
 Sets the z-coordinate of a vector.
 SPAvector (SPAvector const &v)
 C++ copy constructor requests memory for this object and populates it with the data from the object supplied as an argument.
 SPAvector (double v[3])
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAvector (double x, double y, double z)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAvector ()
 C++ allocation constructor requests memory for this object but does not populate it.
double & x ()
 Extracts the x-component of a vector for an update and allows it to be modified.
double x () const
 Returns the x-component of a vector.
double & y ()
 Extracts the y-component of a vector for an update and allows it to be modified.
double y () const
 Returns the y-component of a vector.
double & z ()
 Extracts the z-component of a vector for an update and allows it to be modified.
double z () const
 Extracts the z-component of a vector.

Friends

logical antiparallel (SPAunit_vector const &v1, SPAunit_vector const &v2, const double res)
 Determines if two vectors are anti-parallel (within some resolution).
logical antiparallel (SPAunit_vector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are anti-parallel (within some resolution).
logical antiparallel (SPAvector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are anti-parallel (within some resolution).
logical biparallel (SPAunit_vector const &v1, SPAunit_vector const &v2, const double res)
 Determines if two vectors are bi-parallel (within some resolution).
logical biparallel (SPAunit_vector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are bi-parallel (within some resolution).
logical biparallel (SPAvector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are bi-parallel (within some resolution).
SPAunit_vector normalise (SPAvector const &v)
 Converts a vector into a unit vector.
double operator% (SPAunit_vector const &uv, SPAposition const &p)
 Returns the dot-product of a unit vector and a position.
double operator% (SPAposition const &p, SPAunit_vector const &uv)
 Returns the dot-product of a position and a unit vector.
double operator% (SPAvector const &v, SPAposition const &p)
 Returns the scalar product of vector with a position.
double operator% (SPAposition const &p, SPAvector const &v)
 Returns the scalar product of a position with a vector.
double operator% (SPAvector const &v1, SPAvector const &v2)
 Returns the scalar product (that is, the dot product) of two vectors.
SPAvector operator* (SPAvector const &v, SPAtransf const *t)
 Transforms a vector by an affine transformation.
SPAvector operator* (SPAvector const &v, SPAtransf const &t)
 Transforms a vector by an affine transformation.
SPAvector operator* (SPAvector const &v, SPAmatrix const &m)
 Transforms a vector by a 3 X 3 matrix.
SPAvector operator* (SPAmatrix const &m, SPAvector const &v)
 Transforms a vector by a 3 X 3 matrix.
SPAvector operator* (SPAvector const &v, double d)
 Multiplies a vector by a scalar value.
SPAvector operator* (double d, SPAvector const &v)
 Multiplies a vector by a scalar value.
SPAvector operator* (SPAvector const &v1, SPAvector const &v2)
 Cross product of two vectors - Also applies to unit vectors.
SPAvector operator+ (SPAvector const &v1, SPAvector const &v2)
 Addition of two vectors.
SPAvector operator- (SPAvector const &v1, SPAvector const &v2)
 Binary minus operation.
SPAvector operator- (SPAvector const &nv)
 Unary minus operator.
SPAvector operator/ (SPAvector const &v, double d)
 Division of a vector by a scalar.
logical parallel (SPAunit_vector const &v1, SPAunit_vector const &v2, const double res)
 Determines if two vectors are parallel (within some resolution).
logical parallel (SPAunit_vector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are parallel (within some resolution).
logical parallel (SPAvector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are parallel (within some resolution).
logical perpendicular (SPAunit_vector const &v1, SPAunit_vector const &v2, const double res)
 Determines if two vectors are perpendicular (within some resolution).
logical perpendicular (SPAunit_vector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are perpendicular (within some resolution).
logical perpendicular (SPAvector const &v1, SPAvector const &v2, const double res)
 Determines if two vectors are perpendicular (within some resolution).
logical same_vector (SPAvector const &v1, SPAvector const &v2, const double res)
 Determines whether or not two vectors are the same.


Detailed Description

Represents a displacement vector in 3D Cartesian space.

See also:
SPAtransf

Constructor & Destructor Documentation

SPAvector::SPAvector (  )  [inline]

C++ allocation constructor requests memory for this object but does not populate it.

SPAvector::SPAvector ( double  x,
double  y,
double  z 
) [inline]

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.



Role: Creates a SPAvector from three doubles representing the x, y, and z coordinate values.

Parameters:
x x-coordinate.
y y-coordinate.
z z-coordinate.

SPAvector::SPAvector ( double  v[3]  )  [inline]

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.



Parameters:
v array of 3 doubles.

SPAvector::SPAvector ( SPAvector const &  v  )  [inline]

C++ copy constructor requests memory for this object and populates it with the data from the object supplied as an argument.



Parameters:
v vector.


Member Function Documentation

double& SPAvector::component ( int  i  )  [inline]

Extracts the ith component of a vector and allows it to be modified.



Parameters:
i ith component.

double SPAvector::component ( int  i  )  const [inline]

Returns a copy of the ith component of a vector.



Parameters:
i ith component.

void SPAvector::debug ( FILE *  fp = debug_file_ptr  )  const

Outputs debug information to the screen or to the specified file.



Parameters:
fp file pointer.

void SPAvector::debug_str ( char *  str  )  const

Concatenates the debug information to the passed string.



Parameters:
str string.

logical SPAvector::is_zero ( const double  tol = SPAresabs  )  const

Returns TRUE if the length of the SPAvector is less than the given tolerance.



Parameters:
tol zero tolerance.

double SPAvector::len (  )  const [inline]

Returns the length of the vector.

double SPAvector::len_sq (  )  const [inline]

Returns the length squared, ( x*x + y*y + z*z ).

Faster to compute than calling the len method.

SPAvector SPAvector::make_ortho (  ) 

Returns a SPAvector orthogonal to this SPAvector.

double SPAvector::max_norm ( int &  i  )  const

This method returns the maximum of the fabs of each component, and tells which component was the maximum.



Role: In case of a "tie" the index, i, will default to the larger index. For example, given the vector (1, 1, 1), i = 2.

Parameters:
i index of max component.

double SPAvector::numerically_stable_len (  )  const

Not appropriate for general use.



Role: This method is more expensive than len, but (theoretically) gives the same value and is stable for very small (those for which v%v would be lost in numerical noise) or very large norms (those for which v%v would give overflow).

SPAvector const& SPAvector::operator*= ( SPAtransf const &  t  ) 

Transforms this vector by an affine transformation.



Parameters:
t transform.

Reimplemented in SPAunit_vector.

SPAvector const& SPAvector::operator*= ( SPAmatrix const &  m  )  [inline]

Transforms this vector by a 3 X 3 matrix.

Parameters:
m matrix

SPAvector const& SPAvector::operator*= ( double  d  )  [inline]

Multiplication of a vector by a scalar.



Parameters:
d scalar value.

SPAvector const& SPAvector::operator+= ( SPAvector const &  v  )  [inline]

Adds two vectors.



Parameters:
v vector.

SPAvector const& SPAvector::operator-= ( SPAvector const &  v  )  [inline]

Binary minus operation.



Parameters:
v vector.

SPAvector const& SPAvector::operator/= ( double  d  ) 

Division of a vector by a scalar.



Parameters:
d scalar value.

SPAunit_vector SPAvector::orthogonal (  )  const

Returns a unit vector that is orthogonal to the given vector.

If the given vector is less than SPAresmch in length, this method returns the unit vector (0,0,1).

void SPAvector::set_component ( int  i,
double  new_c 
) [inline]

Sets the value of ith component of a vector.



Parameters:
i ith component.
new_c new value.

void SPAvector::set_x ( double  new_x  )  [inline]

Sets the x-coordinate of a vector.



Parameters:
new_x x-coordinate.

void SPAvector::set_y ( double  new_y  )  [inline]

Sets the y-coordinate of a vector.



Parameters:
new_y y-coordinate.

void SPAvector::set_z ( double  new_z  )  [inline]

Sets the z-coordinate of a vector.



Parameters:
new_z z-coordinate.

double& SPAvector::x (  )  [inline]

Extracts the x-component of a vector for an update and allows it to be modified.

double SPAvector::x (  )  const [inline]

Returns the x-component of a vector.

double& SPAvector::y (  )  [inline]

Extracts the y-component of a vector for an update and allows it to be modified.

double SPAvector::y (  )  const [inline]

Returns the y-component of a vector.

double& SPAvector::z (  )  [inline]

Extracts the z-component of a vector for an update and allows it to be modified.

double SPAvector::z (  )  const [inline]

Extracts the z-component of a vector.


Friends And Related Function Documentation

logical antiparallel ( SPAunit_vector const &  v1,
SPAunit_vector const &  v2,
const double  res 
) [friend]

Determines if two vectors are anti-parallel (within some resolution).

"Anti-parallel" indicates that the vectors are parallel, but in opposite directions. The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical antiparallel ( SPAunit_vector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are anti-parallel (within some resolution).

"Anti-parallel" indicates that the vectors are parallel, but in opposite directions. The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical antiparallel ( SPAvector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are anti-parallel (within some resolution).

"Anti-parallel" indicates that the vectors are parallel, but in opposite directions. The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical biparallel ( SPAunit_vector const &  v1,
SPAunit_vector const &  v2,
const double  res 
) [friend]

Determines if two vectors are bi-parallel (within some resolution).

"Bi-parallel" indicates that the vectors are parallel and may be in either the same or opposite directions. The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical biparallel ( SPAunit_vector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are bi-parallel (within some resolution).

"Bi-parallel" indicates that the vectors are parallel and may be in either the same or opposite directions. The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical biparallel ( SPAvector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are bi-parallel (within some resolution).

"Bi-parallel" indicates that the vectors are parallel and may be in either the same or opposite directions. The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

SPAunit_vector normalise ( SPAvector const &  v  )  [friend]

Converts a vector into a unit vector.



Effect: Read-only

Parameters:
v vector.

Reimplemented in SPAunit_vector.

double operator% ( SPAunit_vector const &  uv,
SPAposition const &  p 
) [friend]

Returns the dot-product of a unit vector and a position.



Parameters:
uv unit vector.
p position.

Reimplemented in SPAunit_vector.

double operator% ( SPAposition const &  p,
SPAunit_vector const &  uv 
) [friend]

Returns the dot-product of a position and a unit vector.



Parameters:
p position.
uv unit vector.

Reimplemented in SPAunit_vector.

double operator% ( SPAvector const &  v,
SPAposition const &  p 
) [friend]

Returns the scalar product of vector with a position.



Parameters:
v vector.
p position.

double operator% ( SPAposition const &  p,
SPAvector const &  v 
) [friend]

Returns the scalar product of a position with a vector.



Parameters:
p position.
v vector.

double operator% ( SPAvector const &  v1,
SPAvector const &  v2 
) [friend]

Returns the scalar product (that is, the dot product) of two vectors.



Parameters:
v1 first vector.
v2 second vector.

SPAvector operator* ( SPAvector const &  v,
SPAtransf const *  t 
) [friend]

Transforms a vector by an affine transformation.



Parameters:
v vector.
t transformation.

SPAvector operator* ( SPAvector const &  v,
SPAtransf const &  t 
) [friend]

Transforms a vector by an affine transformation.



Parameters:
v vector.
t transformation.

SPAvector operator* ( SPAvector const &  v,
SPAmatrix const &  m 
) [friend]

Transforms a vector by a 3 X 3 matrix.



Parameters:
v vector.
m matrix.

SPAvector operator* ( SPAmatrix const &  m,
SPAvector const &  v 
) [friend]

Transforms a vector by a 3 X 3 matrix.



Parameters:
m matrix.
v vector.

SPAvector operator* ( SPAvector const &  v,
double  d 
) [friend]

Multiplies a vector by a scalar value.



Parameters:
v vector.
d scalar value.

SPAvector operator* ( double  d,
SPAvector const &  v 
) [friend]

Multiplies a vector by a scalar value.



Parameters:
d scalar value.
v vector.

SPAvector operator* ( SPAvector const &  v1,
SPAvector const &  v2 
) [friend]

Cross product of two vectors - Also applies to unit vectors.



Parameters:
v1 first vector.
v2 second vector.

SPAvector operator+ ( SPAvector const &  v1,
SPAvector const &  v2 
) [friend]

Addition of two vectors.



Parameters:
v1 first vector.
v2 second vector.

SPAvector operator- ( SPAvector const &  v1,
SPAvector const &  v2 
) [friend]

Binary minus operation.



Parameters:
v1 first vector.
v2 second vector.

SPAvector operator- ( SPAvector const &  nv  )  [friend]

Unary minus operator.



Role: Returns the negation of the given vector.

Parameters:
nv given vector.

SPAvector operator/ ( SPAvector const &  v,
double  d 
) [friend]

Division of a vector by a scalar.



Parameters:
v vector.
d scalar value.

logical parallel ( SPAunit_vector const &  v1,
SPAunit_vector const &  v2,
const double  res 
) [friend]

Determines if two vectors are parallel (within some resolution).

The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical parallel ( SPAunit_vector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are parallel (within some resolution).

The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical parallel ( SPAvector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are parallel (within some resolution).

The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical perpendicular ( SPAunit_vector const &  v1,
SPAunit_vector const &  v2,
const double  res 
) [friend]

Determines if two vectors are perpendicular (within some resolution).

The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical perpendicular ( SPAunit_vector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are perpendicular (within some resolution).

The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical perpendicular ( SPAvector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines if two vectors are perpendicular (within some resolution).

The default tolerance is SPAresnor.

Effect: Read-only

Parameters:
v1 first vector.
v2 second vector.
res resolution.

logical same_vector ( SPAvector const &  v1,
SPAvector const &  v2,
const double  res 
) [friend]

Determines whether or not two vectors are the same.

The default tolerance is SPAresabs.

Effect: System routine

Parameters:
v1 first vector.
v2 second vector.
res resolution for comparison.