DblVector Class Reference

DblVector Class Reference

#include <math.h>

Class Description

Represents a 3D vector or point with S56E11 floating point elements.

Definition at line 348 of file math.h.

Public Member Functions

 DblVector (void) throw ()
 Constructs the vector with zero values. More...
 
Vector Vec () const
 
 DblVector (double fX, double fY, double fZ=0.0) throw ()
 Constructs the vector with specified values. More...
 
 DblVector (const DblVector &vVector) throw ()
 Copy constructor. More...
 
 DblVector (const Vector &vVector) throw ()
 constructor from single precision vector. More...
 
 DblVector (const char *pVector) throw ()
 Construct the vector from a pointer to 8bit signed data. More...
 
 DblVector (const short *pVector) throw ()
 Construct the vector from a pointer to 16bit signed data. More...
 
DblVectorSet (double fX, double fY, double fZ) throw ()
 Sets the values of the vector elements and returns the vector. More...
 
DblVectorClear (void) throw ()
 Zeros all the components of the Vector, then returns it. More...
 
DblVectorNormalize (void) throw ()
 Normalizes the vector and returns it. More...
 
DblVector Normalized (void) const throw ()
 Returns a normalized version of the vector, without changing this vector. More...
 
DblVectorMakeOrthogonal (const DblVector &vBase)
 Makes this vector orthogonal to the given vBase vector and normalizes it. More...
 
DblVectorSetLength (double fLength)
 Sets the vector to the given length, without changing its direction. More...
 
double LengthSquare (void) const
 Returns the square of the length of the DblVector. More...
 
double Length () const throw ()
 Returns the length of the DblVector. More...
 
double Length2D () const throw ()
 Returns the 2D length of the DblVector, ignoring the z element. More...
 
double DistanceFrom (const DblVector &v) const
 Returns the distance between two points (this and another, represented as DblVector objects). More...
 
double DistanceFromLine (const DblVector &v0, const DblVector &v1) const
 Returns the shortest distance between this point and a line defined by two other points (all points represented by DblVector objects). More...
 
double DistanceFromSegment (const DblVector &v0, const DblVector &v1) const
 Returns the distance between this point and a line segment defined by the two ending points. More...
 
double AngleCos (const DblVector &v1) const throw ()
 Returns the cosine of the angle between this vector and the one passed in. More...
 
DblVector Minimum (const DblVector &o)
 Returns the minimum of this and the argument vector. More...
 
DblVector Maximum (const DblVector &o)
 Returns the maximum of this and the argument vector. More...
 
DblVector operator- (void) const throw ()
 Returns the inverse of the vector. More...
 
DblVector operator+ (double f) const throw ()
 Returns the sum of a vector and a scalar. More...
 
DblVector operator+ (const DblVector &v) const throw ()
 Returns the sum of two vectors. More...
 
DblVector operator- (const DblVector &v) const throw ()
 Returns the difference between two DblVectors/points. More...
 
DblVector operator* (const DblVector &v) const throw ()
 Returns the product of two DblVectors by components. More...
 
DblVector operator* (double f) const throw ()
 Returns the product of the DblVector and a scalar. More...
 
DblVector operator/ (const DblVector &v) const throw ()
 Returns the quotient of two DblVectors by components. More...
 
DblVector operator/ (double f) const throw ()
 Returns the quotient of a DblVector and a scalar. More...
 
DblVector operator* (int i) const throw ()
 Returns the product of a DblVector and an integer. More...
 
DblVector operator/ (int i) const throw ()
 Returns the quotient of a DblVector and an integer. More...
 
DblVector operator/ (unsigned int i) const throw ()
 Returns the quotient of a DblVector and an unsigned integer. More...
 
double operator| (const DblVector &v) const throw ()
 Returns the dot product of two DblVectors. More...
 
DblVector operator& (const DblVector &v) const
 Returns the cross product of two DblVectors. More...
 
bool operator== (const DblVector &v) const throw ()
 Returns true if the two DblVectors are identical, false otherwise. More...
 
bool operator!= (const DblVector &v) const throw ()
 Returns true if the two DblVectors are different, false otherwise. More...
 
 operator bool (void) const throw ()
 Returns true if the DblVector is not a zero DblVector, false otherwise. More...
 
bool operator! (void) const throw ()
 Returns true if the DblVector is a zero DblVector, false otherwise. More...
 
DblVectoroperator= (const DblVector &v)
 Sets this DblVector to equal another one and returns it. More...
 
DblVectoroperator<< (const DblVector &v)
 Sets this DblVector to equal another one and returns it. More...
 
DblVectoroperator-= (const DblVector &v) throw ()
 Subtracts the component values of another DblVector from this one's, and returns the result. More...
 
DblVectoroperator+= (const DblVector &v) throw ()
 Adds another DblVector to this one and returns the result. More...
 
DblVectoroperator*= (double f)
 Multiplies the components of the DblVector with a scalar value and returns the result. More...
 
DblVectoroperator*= (const DblVector &v)
 Multiplies the DblVector with another DblVector by components and returns the result. More...
 
DblVectoroperator/= (double f)
 Divides the DblVector by a scalar and returns the result. More...
 
double & operator[] (int i) throw ()
 Returns a individual components of the DblVector. More...
 
double & operator[] (unsigned int i) throw ()
 Returns a component of the DblVector. More...
 
 operator const double * (void) const
 Returns a pointer to the data of the DblVector. Do not delete this pointer. More...
 

Public Attributes

union {
   struct {
      double   m_fX
 
      double   m_fY
 
      double   m_fZ
 
   } 
 
   struct {
      double   x
 
      double   y
 
      double   z
 
   } 
 
   double   m_aCoors [3]
 
}; 
 

Constructor & Destructor Documentation

DblVector ( void  )
throw (
)
inline

Constructs the vector with zero values.

Definition at line 352 of file math.h.

352 { x = y = z = 0.0; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector ( double  fX,
double  fY,
double  fZ = 0.0 
)
throw (
)
inline

Constructs the vector with specified values.

Definition at line 360 of file math.h.

361  { x = fX; y = fY; z = fZ; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector ( const DblVector vVector)
throw (
)
inline

Copy constructor.

Definition at line 364 of file math.h.

365  { x = vVector.x; y = vVector.y; z = vVector.z; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector ( const Vector vVector)
throw (
)
inline

constructor from single precision vector.

Definition at line 368 of file math.h.

369  { x = vVector.x; y = vVector.y; z = vVector.z; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector ( const char *  pVector)
throw (
)
inline

Construct the vector from a pointer to 8bit signed data.

The array must have at least 3 elements, with values in the range -127 to +127.

Definition at line 374 of file math.h.

375  { x = pVector[0]*(1.0/127.0); y = pVector[1]*(1.0/127.0); z = pVector[2]*(1.0/127.0); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector ( const short *  pVector)
throw (
)
inline

Construct the vector from a pointer to 16bit signed data.

The array must have at least 3 elements in the range -32767 to +32767.

Definition at line 379 of file math.h.

380  { x = pVector[0]*(1.0/32767.0); y = pVector[1]*(1.0/32767.0); z = pVector[2]*(1.0/32767.0); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876

Member Function Documentation

Vector Vec ( ) const
inline

Definition at line 355 of file math.h.

355  {
356  return Vector((float)x, (float)y, (float)z);
357  }
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector& Set ( double  fX,
double  fY,
double  fZ 
)
throw (
)
inline

Sets the values of the vector elements and returns the vector.

Definition at line 383 of file math.h.

384  { x = fX; y = fY; z = fZ; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
DblVector& Clear ( void  )
throw (
)
inline

Zeros all the components of the Vector, then returns it.

Definition at line 387 of file math.h.

388  { return Set( 0.0, 0.0, 0.0 ); };
DblVector & Set(double fX, double fY, double fZ)
Sets the values of the vector elements and returns the vector.
Definition: math.h:383
DblVector& Normalize ( void  )
throw (
)

Normalizes the vector and returns it.

If the vector is zero length, it is set to (0,1,0)

DblVector Normalized ( void  ) const
throw (
)

Returns a normalized version of the vector, without changing this vector.

DblVector& MakeOrthogonal ( const DblVector vBase)

Makes this vector orthogonal to the given vBase vector and normalizes it.

Returns the vector.

The resulting vector will lie on the plane defined by the original value of this vector, and vBase.

DblVector& SetLength ( double  fLength)
inline

Sets the vector to the given length, without changing its direction.

If the vector is of zero length, then it is arbitrarily made parallel to the Y axis.

Definition at line 410 of file math.h.

411  { Normalize(); operator *=( fLength ); return *this; };
DblVector & Normalize(void)
Normalizes the vector and returns it.
DblVector & operator*=(double f)
Multiplies the components of the DblVector with a scalar value and returns the result.
Definition: math.h:543
double LengthSquare ( void  ) const
inline

Returns the square of the length of the DblVector.

Definition at line 415 of file math.h.

415 { return x*x+y*y+z*z; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
double z
Definition: math.h:568
GLenum GLint x
Definition: GLee.h:876
double Length ( ) const
throw (
)

Returns the length of the DblVector.

double Length2D ( ) const
throw (
)

Returns the 2D length of the DblVector, ignoring the z element.

double DistanceFrom ( const DblVector v) const
inline

Returns the distance between two points (this and another, represented as DblVector objects).

Definition at line 425 of file math.h.

425 { return operator -(v).Length(); };
DblVector operator-(void) const
Returns the inverse of the vector.
Definition: math.h:451
double Length() const
Returns the length of the DblVector.
const GLdouble * v
Definition: GLee.h:1174
double DistanceFromLine ( const DblVector v0,
const DblVector v1 
) const

Returns the shortest distance between this point and a line defined by two other points (all points represented by DblVector objects).

double DistanceFromSegment ( const DblVector v0,
const DblVector v1 
) const

Returns the distance between this point and a line segment defined by the two ending points.

double AngleCos ( const DblVector v1) const
throw (
)
inline

Returns the cosine of the angle between this vector and the one passed in.

Definition at line 437 of file math.h.

438  { return DblVector(*this).Normalize()|DblVector(v1).Normalize(); };
GLfloat GLfloat v1
Definition: GLee.h:1735
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
DblVector Minimum ( const DblVector o)
inline

Returns the minimum of this and the argument vector.

Minimums are calculated individually for z, y, and z.

Definition at line 442 of file math.h.

443  { return DblVector( Min(x, o.x), Min(y, o.y), Min(z, o.z) ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
type Min(type a, type b)
Definition: mudbox.h:184
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
DblVector Maximum ( const DblVector o)
inline

Returns the maximum of this and the argument vector.

Maximums are calculated individually for z, y, and z.

Definition at line 447 of file math.h.

448  { return DblVector( Max(x, o.x), Max(y, o.y), Max(z, o.z) ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
type Max(type a, type b)
Definition: mudbox.h:186
DblVector operator- ( void  ) const
throw (
)
inline

Returns the inverse of the vector.

Definition at line 451 of file math.h.

452  { return DblVector( -x, -y, -z ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
DblVector operator+ ( double  f) const
throw (
)
inline

Returns the sum of a vector and a scalar.

(The scalar is added to each component individually).

Definition at line 456 of file math.h.

457  { return DblVector( x+f, y+f, z+f ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
GLclampf f
Definition: GLee.h:9303
DblVector operator+ ( const DblVector v) const
throw (
)
inline

Returns the sum of two vectors.

Definition at line 460 of file math.h.

461  { return DblVector( x+v.x, y+v.y, z+v.z ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector operator- ( const DblVector v) const
throw (
)
inline

Returns the difference between two DblVectors/points.

Definition at line 464 of file math.h.

465  { return DblVector( x-v.x, y-v.y, z-v.z ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector operator* ( const DblVector v) const
throw (
)
inline

Returns the product of two DblVectors by components.

Definition at line 468 of file math.h.

469  { return DblVector( x*v.x, y*v.y, z*v.z ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector operator* ( double  f) const
throw (
)
inline

Returns the product of the DblVector and a scalar.

Definition at line 472 of file math.h.

473  { return DblVector( x*f, y*f, z*f ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
GLclampf f
Definition: GLee.h:9303
DblVector operator/ ( const DblVector v) const
throw (
)
inline

Returns the quotient of two DblVectors by components.

Definition at line 476 of file math.h.

477  { return DblVector( x/v.x, y/v.y, z/v.z ); };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector operator/ ( double  f) const
throw (
)
inline

Returns the quotient of a DblVector and a scalar.

Definition at line 480 of file math.h.

481  { return operator *( 1.0/f ); };
DblVector operator*(const DblVector &v) const
Returns the product of two DblVectors by components.
Definition: math.h:468
GLclampf f
Definition: GLee.h:9303
DblVector operator* ( int  i) const
throw (
)
inline

Returns the product of a DblVector and an integer.

Definition at line 484 of file math.h.

485  { return operator *( double(i) ); };
DblVector operator*(const DblVector &v) const
Returns the product of two DblVectors by components.
Definition: math.h:468
DblVector operator/ ( int  i) const
throw (
)
inline

Returns the quotient of a DblVector and an integer.

Definition at line 488 of file math.h.

489  { return operator /( double(i) ); };
DblVector operator/(const DblVector &v) const
Returns the quotient of two DblVectors by components.
Definition: math.h:476
DblVector operator/ ( unsigned int  i) const
throw (
)
inline

Returns the quotient of a DblVector and an unsigned integer.

Definition at line 492 of file math.h.

493  { return operator /( double(i) ); };
DblVector operator/(const DblVector &v) const
Returns the quotient of two DblVectors by components.
Definition: math.h:476
double operator| ( const DblVector v) const
throw (
)
inline

Returns the dot product of two DblVectors.

Definition at line 496 of file math.h.

497  { return x*v.x+y*v.y+z*v.z; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector operator& ( const DblVector v) const
inline

Returns the cross product of two DblVectors.

Definition at line 500 of file math.h.

501  {
502  DblVector vR;
503  vR.m_fX = m_fY*v.m_fZ-m_fZ*v.m_fY;
504  vR.m_fY = m_fZ*v.m_fX-m_fX*v.m_fZ;
505  vR.m_fZ = m_fX*v.m_fY-m_fY*v.m_fX;
506  return vR;
507  };
double m_fX
Definition: math.h:567
DblVector(void)
Constructs the vector with zero values.
Definition: math.h:352
double m_fZ
Definition: math.h:567
const GLdouble * v
Definition: GLee.h:1174
double m_fY
Definition: math.h:567
bool operator== ( const DblVector v) const
throw (
)
inline

Returns true if the two DblVectors are identical, false otherwise.

Definition at line 511 of file math.h.

512  { return x == v.x && y == v.y && z == v.z; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
bool operator!= ( const DblVector v) const
throw (
)
inline

Returns true if the two DblVectors are different, false otherwise.

Definition at line 515 of file math.h.

516  { return !operator ==( v ); };
bool operator==(const DblVector &v) const
Returns true if the two DblVectors are identical, false otherwise.
Definition: math.h:511
const GLdouble * v
Definition: GLee.h:1174
operator bool ( void  ) const
throw (
)
inline

Returns true if the DblVector is not a zero DblVector, false otherwise.

Definition at line 519 of file math.h.

519 { return x || y || z; };
GLenum GLint GLint y
Definition: GLee.h:876
double z
Definition: math.h:568
GLenum GLint x
Definition: GLee.h:876
bool operator! ( void  ) const
throw (
)
inline

Returns true if the DblVector is a zero DblVector, false otherwise.

Definition at line 522 of file math.h.

522 { return !operator bool(); };
DblVector& operator= ( const DblVector v)
inline

Sets this DblVector to equal another one and returns it.

Definition at line 525 of file math.h.

526  { x = v.x; y = v.y; z = v.z; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector& operator<< ( const DblVector v)
inline

Sets this DblVector to equal another one and returns it.

Definition at line 529 of file math.h.

530  { x = v.x; y = v.y; z = v.z; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector& operator-= ( const DblVector v)
throw (
)
inline

Subtracts the component values of another DblVector from this one's, and returns the result.

Definition at line 534 of file math.h.

535  { x-=v.x; y-=v.y; z-=v.z; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector& operator+= ( const DblVector v)
throw (
)
inline

Adds another DblVector to this one and returns the result.

Definition at line 538 of file math.h.

539  { x+=v.x; y+=v.y; z+=v.z; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector& operator*= ( double  f)
inline

Multiplies the components of the DblVector with a scalar value and returns the result.

Definition at line 543 of file math.h.

543 { x *= f; y *= f; z *= f; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
GLclampf f
Definition: GLee.h:9303
DblVector& operator*= ( const DblVector v)
inline

Multiplies the DblVector with another DblVector by components and returns the result.

Definition at line 547 of file math.h.

548  { x *= v.x; y *= v.y; z *= v.z; return *this; };
GLenum GLint GLint y
Definition: GLee.h:876
GLdouble GLdouble z
Definition: GLee.h:1393
GLenum GLint x
Definition: GLee.h:876
const GLdouble * v
Definition: GLee.h:1174
DblVector& operator/= ( double  f)
inline

Divides the DblVector by a scalar and returns the result.

Definition at line 551 of file math.h.

551 { return operator *=( 1.0/f ); };
DblVector & operator*=(double f)
Multiplies the components of the DblVector with a scalar value and returns the result.
Definition: math.h:543
GLclampf f
Definition: GLee.h:9303
double& operator[] ( int  i)
throw (
)
inline

Returns a individual components of the DblVector.

Parameters
[in]iAllowed range: 0 to 2.

Definition at line 554 of file math.h.

556  { return m_aCoors[i]; };
double m_aCoors[3]
Definition: math.h:569
double& operator[] ( unsigned int  i)
throw (
)
inline

Returns a component of the DblVector.

Parameters
[in]iAllowed range: 0 to 2.

Definition at line 559 of file math.h.

561  { return m_aCoors[i]; };
double m_aCoors[3]
Definition: math.h:569
operator const double * ( void  ) const
inline

Returns a pointer to the data of the DblVector. Do not delete this pointer.

Definition at line 564 of file math.h.

564 { return &x; };
double x
Definition: math.h:568

Member Data Documentation

double m_fX

Definition at line 567 of file math.h.

double m_fY

Definition at line 567 of file math.h.

double m_fZ

Definition at line 567 of file math.h.

double x

Definition at line 568 of file math.h.

double y

Definition at line 568 of file math.h.

double z

Definition at line 568 of file math.h.

double m_aCoors[3]

Definition at line 569 of file math.h.

union { ... }

The documentation for this class was generated from the following file: