Class IPoint3
See Also: Class Point3.
class IPoint3
Description:
This class describes a 3D point using integer 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.
Methods:
Data Members:
public:
int x,y,z;
Prototype:
IPoint3()
Remarks:
Constructor. No initialization is performed.
Prototype:
IPoint3(int X, int Y, int Z)
Remarks:
Constructor. x, y, and z are initialized to the values specified.
Prototype:
IPoint3(const IPoint3& a)
Remarks:
Constructor. x, y, and z are initialized to the IPoint3 specified.
Prototype:
IPoint3(int ai[3])
Remarks:
Constructor. x, y, and z are initialized to. ai[0], ai[1], and ai[2] respectively.
Prototype:
int DotProd(const IPoint3&) const;
Remarks:
Returns the dot product of two IPoint3s.
Prototype:
IPoint3 CrossProd(const IPoint3&) const;
Remarks:
Returns the cross product of two IPoint3's (vectors).
Operators:
Prototype:
int& operator[](int i)
const int& operator[](int i) const
Remarks:
Allows access to x, y and z using the [ ] operator.
Return Value:
An index of 0 will return x, 1 will return y, 2 will return z.
Prototype:
operator int*()
Remarks:
Conversion function. Returns the address of the IPoint3.
Prototype:
IPoint3 operator-() const
Remarks:
Unary - operator. Negates x, y and z.
Prototype:
IPoint3 operator+() const
Remarks:
Unary +. Returns the point unaltered.
Prototype:
IPoint3& operator-=(const IPoint3&);
Remarks:
Subtracts a IPoint3 from this IPoint3.
Prototype:
IPoint3& operator+=(const IPoint3&);
Remarks:
Adds a IPoint3 to this IPoint3.
Prototype:
IPoint3 operator-(const IPoint3&) const;
Remarks:
Subtracts a IPoint3 from a IPoint3.
Prototype:
IPoint3 operator+(const IPoint3&) const;
Remarks:
Adds a IPoint3 to a IPoint3.
Prototype:
int operator*(const IPoint3&) const;
Remarks:
Returns the dot product of two IPoint3s.
Prototype:
IPoint3 operator^(const IPoint3&) const;
Remarks:
The cross product of two IPoint3's (vectors).
Prototype:
int operator==(const IPoint3& p) const
Remarks:
Test for equality between two IPoint3's.
Return Value:
Nonzero if the IPoint3's are equal; otherwise 0.
The following functions are not members of IPoint3 but are available for use:
Prototype:
int MaxComponent(const IPoint3&);
Remarks:
Returns the component with the maximum absolute value. 0=x, 1=y, 2=z.
Prototype:
int MinComponent(const IPoint3&);
Remarks:
Returns the component with the minimum absolute value. 0=x, 1=y, 2=z.
Prototype:
inline float Length(const IPoint3& v)
Remarks:
Returns the 'Length' of the point. This is sqrt(v.x*v.x+v.y*v.y+v.z*v.z)
Prototype:
ostream &operator<<(ostream&, const IPoint3&);
Remarks:
Formats the IPoint3 for output as in:
(x, y, z)