Home

SPAunit_vector Class Reference
[Geometric Atoms]

Provides a direction in 3D Cartesian space that has unit length. More...

#include <unitvec.hxx>

Inheritance diagram for SPAunit_vector:

Inheritance graph
[legend]
Collaboration diagram for SPAunit_vector:

Collaboration 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*= (SPAmatrix const &m)
 Transforms this vector by a 3 X 3 matrix.
SPAvector const & operator*= (double d)
 Multiplication of a vector by a scalar.
SPAunit_vector const & operator*= (SPAtransf const &t)
 Transforms a unit vector by the rotation matrix in a transformation.
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.
 SPAunit_vector (double u[3])
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAunit_vector (double x, double y, double z)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAunit_vector ()
 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

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.
SPAunit_vector operator* (SPAunit_vector const &uv, SPAtransf const *t)
 Transforms a unit vector by the rotation matrix in a transformation.
SPAunit_vector operator* (SPAunit_vector const &uv, SPAtransf const &t)
 Transforms a unit vector by the rotation matrix in a transformation.
SPAposition operator* (SPAunit_vector const &uv, SPAposition const &p)
 Returns the cross product of a unit vector with a position.
SPAposition operator* (SPAposition const &p, SPAunit_vector const &uv)
 Returns the cross product of a position with a unit vector.
SPAunit_vector operator- (SPAunit_vector const &uv)
 Performs a unary minus operation.


Detailed Description

Provides a direction in 3D Cartesian space that has unit length.


Role: This class provides a direction in 3D Cartesian space that has unit length. Because it is a derived class of vector, it inherits the functionality of vectors. There are a few operations that are peculiar to unit vectors.

See also:
SPAtransf

Constructor & Destructor Documentation

SPAunit_vector::SPAunit_vector (  )  [inline]

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

SPAunit_vector::SPAunit_vector ( double  x,
double  y,
double  z 
)

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.

SPAunit_vector::SPAunit_vector ( double  u[3]  ) 

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



Parameters:
u array of 3 doubles.


Member Function Documentation

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

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



Parameters:
i ith component.

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

Returns a copy of the ith component of a vector.



Parameters:
i ith component.

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

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



Parameters:
fp file pointer.

void SPAvector::debug_str ( char *  str  )  const [inherited]

Concatenates the debug information to the passed string.



Parameters:
str string.

logical SPAvector::is_zero ( const double  tol = SPAresabs  )  const [inherited]

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



Parameters:
tol zero tolerance.

double SPAvector::len (  )  const [inline, inherited]

Returns the length of the vector.

double SPAvector::len_sq (  )  const [inline, inherited]

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

Faster to compute than calling the len method.

SPAvector SPAvector::make_ortho (  )  [inherited]

Returns a SPAvector orthogonal to this SPAvector.

double SPAvector::max_norm ( int &  i  )  const [inherited]

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 [inherited]

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*= ( SPAmatrix const &  m  )  [inline, inherited]

Transforms this vector by a 3 X 3 matrix.

Parameters:
m matrix

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

Multiplication of a vector by a scalar.



Parameters:
d scalar value.

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

Transforms a unit vector by the rotation matrix in a transformation.



Role: This method returns an error if the transformation contains a shear component.

Parameters:
t transform.

Reimplemented from SPAvector.

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

Adds two vectors.



Parameters:
v vector.

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

Binary minus operation.



Parameters:
v vector.

SPAvector const& SPAvector::operator/= ( double  d  )  [inherited]

Division of a vector by a scalar.



Parameters:
d scalar value.

SPAunit_vector SPAvector::orthogonal (  )  const [inherited]

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, inherited]

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, inherited]

Sets the x-coordinate of a vector.



Parameters:
new_x x-coordinate.

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

Sets the y-coordinate of a vector.



Parameters:
new_y y-coordinate.

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

Sets the z-coordinate of a vector.



Parameters:
new_z z-coordinate.

double& SPAvector::x (  )  [inline, inherited]

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

double SPAvector::x (  )  const [inline, inherited]

Returns the x-component of a vector.

double& SPAvector::y (  )  [inline, inherited]

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

double SPAvector::y (  )  const [inline, inherited]

Returns the y-component of a vector.

double& SPAvector::z (  )  [inline, inherited]

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

double SPAvector::z (  )  const [inline, inherited]

Extracts the z-component of a vector.


Friends And Related Function Documentation

SPAunit_vector normalise ( SPAvector const &  v  )  [friend]

Converts a vector into a unit vector.



Effect: Read-only

Parameters:
v vector.

Reimplemented from SPAvector.

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 from SPAvector.

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 from SPAvector.

SPAunit_vector operator* ( SPAunit_vector const &  uv,
SPAtransf const *  t 
) [friend]

Transforms a unit vector by the rotation matrix in a transformation.



Role: This method returns an error if the transformation contains a shear component.

Parameters:
uv unit vector.
t transformation.

SPAunit_vector operator* ( SPAunit_vector const &  uv,
SPAtransf const &  t 
) [friend]

Transforms a unit vector by the rotation matrix in a transformation.



Role: This method returns an error if the transformation contains a shear component.

Parameters:
uv unit vector.
t transformation.

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

Returns the cross product of a unit vector with a position.



Parameters:
uv unit vector.
p position.

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

Returns the cross product of a position with a unit vector.



Parameters:
p position.
uv unit vector.

SPAunit_vector operator- ( SPAunit_vector const &  uv  )  [friend]

Performs a unary minus operation.



Parameters:
uv unit vector.