DPoint3 Class Reference

#include <dpoint3.h>

Class Description

class DPoint3 Description: This class describes a 3D point using double precision x, y and z coordinates.

Methods are provided to add and subtract points, multiply and divide by scalars, and element by element multiply and divide two points. All methods are implemented by the system. Data Members: double x,y,z;

+ Inheritance diagram for DPoint3:

Public Member Functions

 DPoint3 ()
 Initializes all vector components to zero. More...
 
 DPoint3 (double X, double Y, double Z)
 Constructor. More...
 
 DPoint3 (const DPoint3 &a)
 Constructor. More...
 
 DPoint3 (const Point3 &a)
 
 DPoint3 (const double af[3])
 Constructor. More...
 
double & operator[] (int i)
 Allows access to x, y and z using the subscript operator. More...
 
const double & operator[] (int i) const
 Allows access to x, y and z using the subscript operator. More...
 
 operator double * ()
 Conversion function. More...
 
DPoint3 operator- () const
 Unary - operator. More...
 
DPoint3 operator+ () const
 Unary +. More...
 
DPoint3operator= (const Point3 &a)
 
DPoint3operator-= (const DPoint3 &)
 Subtracts a DPoint3 from this DPoint3. More...
 
DPoint3operator+= (const DPoint3 &)
 Adds a DPoint3 to this DPoint3. More...
 
DPoint3operator*= (const DPoint3 &)
 Member-wise multiplication of two vectors: (x*x, y*y, z*z) More...
 
DPoint3operator*= (double)
 Each element of this DPoint3 is multiplied by the specified double. More...
 
DPoint3operator/= (double)
 Each element of this DPoint3 is divided by the specified double. More...
 
DPoint3 operator- (const DPoint3 &) const
 Subtracts a DPoint3 from a DPoint3. More...
 
DPoint3 operator+ (const DPoint3 &) const
 Adds a DPoint3 to a DPoint3. More...
 
DPoint3 operator* (const DPoint3 &) const
 Member-wise multiplication of two vectors: (x*x, y*y, z*z) More...
 
DPoint3 operator^ (const DPoint3 &) const
 Computes the cross product of this DPoint3 and the specified DPoint3. More...
 
double Length () const
 Returns the 'Length' of this point (vector). More...
 
double LengthSquared () const
 The 'Length' squared of this point. More...
 
DPoint3Unify ()
 in place normalize More...
 
int MaxComponent () const
 
int MinComponent () const
 
int operator== (const DPoint3 &p) const
 Equality operator. More...
 
int operator!= (const DPoint3 &p) const
 Equality operator. More...
 

Public Attributes

double x
 
double y
 
double z
 

Static Public Attributes

static const DPoint3 Origin
 const for (0,0,0) More...
 
static const DPoint3 XAxis
 const for (1,0,0) More...
 
static const DPoint3 YAxis
 const for (0,1,0) More...
 
static const DPoint3 ZAxis
 const for (0,0,1) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

DPoint3 ( )
inline

Initializes all vector components to zero.

29 : x(0.0), y(0.0), z(0.0) {}
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 ( double  X,
double  Y,
double  Z 
)
inline

Constructor.

x, y, and z are initialized to the values specified.

32 { x = X; y = Y; z = Z; }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 ( const DPoint3 a)
inline

Constructor.

x, y, and z are initialized to the DPoint3 specified.

35 { x = a.x; y = a.y; z = a.z; }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 ( const Point3 a)
inline
36 { x = a.x; y = a.y; z = a.z; }
float y
Definition: point3.h:55
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
float z
Definition: point3.h:55
float x
Definition: point3.h:55
DPoint3 ( const double  af[3])
inline

Constructor.

x, y, and z are initialized to. af[0], af[1], and af[2] respectively. Operators:

41 { x = af[0]; y = af[1]; z = af[2]; }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26

Member Function Documentation

double& operator[] ( int  i)
inline

Allows access to x, y and z using the subscript operator.

Returns
An index of 0 will return x, 1 will return y, 2 will return z.
46 { DbgAssert((i >= 0) && (i <= 2)); return (&x)[i]; }
double x
Definition: dpoint3.h:26
#define DbgAssert(expr)
Definition: assert1.h:72
const double& operator[] ( int  i) const
inline

Allows access to x, y and z using the subscript operator.

Returns
An index of 0 will return x, 1 will return y, 2 will return z.
49 { DbgAssert((i >= 0) && (i <= 2)); return (&x)[i]; }
double x
Definition: dpoint3.h:26
#define DbgAssert(expr)
Definition: assert1.h:72
operator double * ( )
inline

Conversion function.

Returns the address of the DPoint3.x

53 { return(&x); }
double x
Definition: dpoint3.h:26
DPoint3 operator- ( ) const
inline

Unary - operator.

Negates both x, y and z.

57 { return(DPoint3(-x,-y,-z)); }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
DPoint3()
Initializes all vector components to zero.
Definition: dpoint3.h:29
double x
Definition: dpoint3.h:26
DPoint3 operator+ ( ) const
inline

Unary +.

Returns the point unaltered.

59 { return *this; }
DPoint3& operator= ( const Point3 a)
inline
62 { x = a.x; y = a.y; z = a.z; return *this; }
float y
Definition: point3.h:55
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
float z
Definition: point3.h:55
float x
Definition: point3.h:55
DPoint3 & operator-= ( const DPoint3 a)
inline

Subtracts a DPoint3 from this DPoint3.

157  {
158  x -= a.x; y -= a.y; z -= a.z;
159  return *this;
160  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 & operator+= ( const DPoint3 a)
inline

Adds a DPoint3 to this DPoint3.

162  {
163  x += a.x; y += a.y; z += a.z;
164  return *this;
165  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 & operator*= ( const DPoint3 rhs)
inline

Member-wise multiplication of two vectors: (x*x, y*y, z*z)

168 {
169  x *= rhs.x;
170  y *= rhs.y;
171  z *= rhs.z;
172  return *this;
173 }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 & operator*= ( double  f)
inline

Each element of this DPoint3 is multiplied by the specified double.

175  {
176  x *= f; y *= f; z *= f;
177  return *this;
178  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 & operator/= ( double  f)
inline

Each element of this DPoint3 is divided by the specified double.

180  {
181  x /= f; y /= f; z /= f;
182  return *this;
183  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
DPoint3 operator- ( const DPoint3 b) const
inline

Subtracts a DPoint3 from a DPoint3.

185  {
186  return(DPoint3(x-b.x,y-b.y,z-b.z));
187  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
DPoint3()
Initializes all vector components to zero.
Definition: dpoint3.h:29
double x
Definition: dpoint3.h:26
DPoint3 operator+ ( const DPoint3 b) const
inline

Adds a DPoint3 to a DPoint3.

189  {
190  return(DPoint3(x+b.x,y+b.y,z+b.z));
191  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
DPoint3()
Initializes all vector components to zero.
Definition: dpoint3.h:29
double x
Definition: dpoint3.h:26
DPoint3 operator* ( const DPoint3 b) const
inline

Member-wise multiplication of two vectors: (x*x, y*y, z*z)

193  {
194  return DPoint3(x * b.x, y * b.y, z * b.z);
195  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
DPoint3()
Initializes all vector components to zero.
Definition: dpoint3.h:29
double x
Definition: dpoint3.h:26
DPoint3 operator^ ( const DPoint3 ) const

Computes the cross product of this DPoint3 and the specified DPoint3.

double Length ( ) const

Returns the 'Length' of this point (vector).

This is:

sqrt(v.x*v.x+v.y*v.y+v.z*v.z)

double LengthSquared ( ) const

The 'Length' squared of this point.

This is v.x*v.x+v.y*v.y+v.z*v.z.

DPoint3& Unify ( )

in place normalize

int MaxComponent ( ) const
Returns
The largest axis
int MinComponent ( ) const
Returns
The smallest axis
int operator== ( const DPoint3 p) const
inline

Equality operator.

Test for equality between two Point3's.

Returns
Nonzero if the Point3's are equal; otherwise 0.
108  {
109  return ((p.x==x)&&(p.y==y)&&(p.z==z));
110  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26
int operator!= ( const DPoint3 p) const
inline

Equality operator.

Test for nonequality between two Point3's.

Returns
Nonzero if the Point3's are not equal; otherwise 0.
113  {
114  return ((p.x!=x)||(p.y!=y)||(p.z!=z));
115  }
double y
Definition: dpoint3.h:26
double z
Definition: dpoint3.h:26
double x
Definition: dpoint3.h:26

Member Data Documentation

double x
double y
double z
const DPoint3 Origin
static

const for (0,0,0)

const DPoint3 XAxis
static

const for (1,0,0)

const DPoint3 YAxis
static

const for (0,1,0)

const DPoint3 ZAxis
static

const for (0,0,1)