Class DPoint3
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:
public:
double x,y,z;
Methods:
Prototype:
DPoint3()
Remarks:
Constructor. No initialization is performed.
Prototype:
DPoint3(double X, double Y, double Z)
Remarks:
Constructor. x, y, and z are initialized to the values specified.
Prototype:
DPoint3(const DPoint3& a)
Remarks:
Constructor. x, y, and z are initialized to the DPoint3 specified.
Prototype:
DPoint3(double af[3])
Remarks:
Constructor. x, y, and z are initialized to. af[0], af[1], and af[2] respectively.
Operators:
Prototype:
double& operator[](int i)
const double& operator[](int i) const
Remarks:
Allows access to x, y and z using the subscript operator.
Return Value:
An index of 0 will return x, 1 will return y, 2 will return z.
Prototype:
operator double*()
Remarks:
Conversion function. Returns the address of the DPoint3.x
Prototype:
DPoint3 operator-() const
Remarks:
Unary - operator. Negates both x, y and z.
Prototype:
DPoint3 operator+() const
Remarks:
Unary +. Returns the point unaltered.
Prototype:
DPoint3& operator-=(const DPoint3&);
Remarks:
Subtracts a DPoint3 from this DPoint3.
Prototype:
DPoint3& operator+=(const DPoint3&);
Remarks:
Adds a DPoint3 to this DPoint3.
Prototype:
DPoint3& operator*=(double);
Remarks:
Each element of this DPoint3 is multiplied by the specified double.
Prototype:
DPoint3& operator/=(double);
Remarks:
Each element of this DPoint3 is divided by the specified double.
Prototype:
DPoint3 operator-(const DPoint3&) const;
Remarks:
Subtracts a DPoint3 from a DPoint3.
Prototype:
DPoint3 operator+(const DPoint3&) const;
Remarks:
Adds a DPoint3 to a DPoint3.
Prototype:
double operator*(const DPoint3&) const;
Remarks:
Computes the dot product of this DPoint3 and the specified DPoint3.
Prototype:
DPoint3 operator^(const DPoint3&) const;
Remarks:
Computes the cross product of this DPoint3 and the specified DPoint3.
The following functions are not methods of DPoint3 but are available for use:
Prototype:
double Length(const DPoint3&);
Remarks:
Returns the 'Length' of the point. This is sqrt(v.x*v.x+v.y*v.y+v.z*v.z)
Prototype:
int MaxComponent(const DPoint3&);
Remarks:
Returns the component with the maximum absolute value. 0=x, 1=y, 2=z.
Prototype:
int MinComponent(const DPoint3&);
Remarks:
Returns the component with the minimum absolute value. 0=x, 1=y, 2=z.
Prototype:
DPoint3 Normalize(const DPoint3&);
Remarks:
Returns a unit vector. This is a DPoint3 with each component divided by the point Length().
Prototype:
DPoint3 CrossProd(const DPoint3& a, const DPoint3& b);
Remarks:
Returns the cross product of two DPoint3s.
Prototype:
double DotProd(const DPoint3& a, const DPoint3& b);
Remarks:
Returns the dot product of two DPoint3s.