Public Member Functions | Public Attributes | Static Public Attributes

Point4 Class Reference

This reference page is linked to from the following overview topics: Parameter Types.


Search for all occurrences

Detailed Description

See also:
Class Point3.

Description:
This class describes a point using float x, y, z and w 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.

This class is available in release 2.0 and later only.
Data Members:
float x, y, z, w;

The x, y, z and w components of the point.

static const Point4 Origin;

This is equivalent to Point4(0.0f, 0.0f, 0.0f, 0.0f);

static const Point4 XAxis;

This is equivalent to Point4(1.0f, 0.0f, 0.0f, 0.0f);

static const Point4 YAxis;

This is equivalent to Point4(0.0f,1.0f, 0.0f, 0.0f);

static const Point4 ZAxis;

This is equivalent to Point4(0.0f, 0.0f,1.0f, 0.0f);

static const Point4 WAxis;

This is equivalent to Point4(0.0f, 0.0f, 0.0f,1.0f);

#include <point4.h>

Inheritance diagram for Point4:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  Point4 ()
  Point4 (float X, float Y, float Z, float W)
  Point4 (double X, double Y, double Z, double W)
  Point4 (int X, int Y, int Z, int W)
  Point4 (const Point3 &a, float W=0.0f)
  Point4 (const Point4 &a)
  Point4 (float af[4])
float &  operator[] (int i)
const float &  operator[] (int i) const
  operator float * ()
Point4  operator- () const
Point4  operator+ () const
float  Length () const
float  FLength () const
float  LengthSquared () const
int  MaxComponent () const
int  MinComponent () const
Point4  Normalize () const
Point4  FNormalize () const
Point4 operator-= (const Point4 &)
Point4 operator+= (const Point4 &)
Point4 operator*= (float)
Point4 operator/= (float)
Point4 operator*= (const Point4 &)
Point4 Set (float X, float Y, float Z, float W)
int  operator== (const Point4 &p) const
int  operator!= (const Point4 &p) const
int  Equals (const Point4 &p, float epsilon=1E-6f)
Point4 Unify ()
float  LengthUnify ()
Point4  operator- (const Point4 &) const
Point4  operator+ (const Point4 &) const
Point4  operator/ (const Point4 &) const
Point4  operator* (const Point4 &) const
float  operator% (const Point4 &) const

Public Attributes

float  x
float  y
float  z
float  w

Static Public Attributes

static const Point4  Origin
static const Point4  XAxis
static const Point4  YAxis
static const Point4  ZAxis
static const Point4  WAxis

Constructor & Destructor Documentation

Point4 ( ) [inline]
Remarks:
Constructor. No initialization is performed.
{  /* NO INIT */}
Point4 ( float  X,
float  Y,
float  Z,
float  W 
) [inline]
Remarks:
Constructor. x, y, z and w are initialized to the values specified.
                                               { 
         x = X; y = Y; z = Z; w = W; 
     }
Point4 ( double  X,
double  Y,
double  Z,
double  W 
) [inline]
Remarks:
Constructor. x, y, z and w are initialized to the specified values (cast as floats).
                                                  { 
         x = (float)X; y = (float)Y; z = (float)Z; w = (float)W; 
     }
Point4 ( int  X,
int  Y,
int  Z,
int  W 
) [inline]
Remarks:
Constructor. x, y, z and w are initialized to the specified values (cast as floats).
                                      { 
         x = (float)X; y = (float)Y; z = (float)Z; w = (float)W; 
     }
Point4 ( const Point3 a,
float  W = 0.0f 
) [inline]
Remarks:
Constructor. x, y, z and w are initialized to the specified Point3 and W.
                                         { 
         x = a.x; y = a.y; z = a.z; w = W; 
     } 
Point4 ( const Point4 a ) [inline]
                             { 
         x = a.x; y = a.y; z = a.z; w = a.w; 
     } 
Point4 ( float  af[4] ) [inline]
Remarks:
Constructor. x, y, z and w are initialized to af[0], af[1], af[2] and af[3] respectively.
                       { 
         x = af[0]; y = af[1]; z = af[2]; w = af[3]; 
     }

Member Function Documentation

float& operator[] ( int  i ) [inline]
Remarks:
Allows access to x, y, z and w using the subscript operator.
Returns:
An value for i of 0 will return x, 1 will return y, 2 will return z and 3 will return w.
                           { 
         return (&x)[i];
     }     
const float& operator[] ( int  i ) const [inline]
Remarks:
Allows access to x, y, z and w using the subscript operator.
Returns:
An value for i of 0 will return x, 1 will return y, 2 will return z and 3 will return w.
                                        { 
         return (&x)[i]; 
     }  
operator float * ( ) [inline]
Remarks:
Conversion function. Returns the address of the Point4.x
                     { 
         return(&x); 
     }
Point4 operator- ( ) const [inline]
Remarks:
Unary - operator. Negates x, y, z and w.
                            { 
         return(Point4(-x,-y,-z, -w)); 
     } 
Point4 operator+ ( ) const [inline]
Remarks:
Unary +. Returns the Point4.
                            { 
         return *this; 
     } 
float Length ( ) const [inline]
                                  {  
   return (float)sqrt(x*x+y*y+z*z+w*w);
}
float FLength ( ) const [inline]
                                   { 
   return Sqrt(x*x+y*y+z*z+w*w);
}
float LengthSquared ( ) const [inline]
                                         { 
   return (x*x+y*y+z*z+w*w);
}
int MaxComponent ( ) const
int MinComponent ( ) const
Point4 Normalize ( ) const
Point4 FNormalize ( ) const
Point4 & operator-= ( const Point4 a ) [inline]
Remarks:
Subtracts a Point4 from this Point4.
Returns:
A Point4 that is the difference between two Point4s.
                                                 {  
   x -= a.x;   y -= a.y;   z -= a.z; w -= a.w;

   return *this;
   }
Point4 & operator+= ( const Point4 a ) [inline]
Remarks:
Adds a Point4 to this Point4.
Returns:
A Point4 that is the sum of two Point4s.
                                                 {
   x += a.x;   y += a.y;   z += a.z; w += a.w;
   return *this;
   }
Point4 & operator*= ( float  f ) [inline]
Remarks:
Multiplies this Point4 by a floating point value.
Returns:
A Point4 multiplied by a float.
                                         {
   x *= f;   y *= f; z *= f; w *= f;

   return *this;
   }
Point4 & operator/= ( float  f ) [inline]
Remarks:
Divides this Point4 by a floating point value.
Returns:
A Point4 divided by a float.
                                         { 
   if (f==0.0f) f = .000001f;
   x /= f;  y /= f;  z /= f;   w /= f;

   return *this; 
   }
Point4 & operator*= ( const Point4 a ) [inline]
Remarks:
Element-by-element multiplication of two Point4s:

(x*x, y*y, z*z, w*w).
Returns:
A Point4 element-by-element multiplied by another Point4.
                                                 { 
   x *= a.x;   y *= a.y;   z *= a.z;   w *= a.w;

   return *this; 
   }
Point4 & Set ( float  X,
float  Y,
float  Z,
float  W 
) [inline]
Remarks:
Sets the x, y, z and w coordinate to the values passed and returns a reference to this Point4.
Parameters:
float X

The new x value.

float Y

The new y value.

float Z

The new z value.

float W

The new w value.
Returns:
A reference to this Point4.
                                                             {
    x = X;
    y = Y;
    z = Z;
    w = W;

    return *this;
    }
int operator== ( const Point4 p ) const [inline]
Remarks:
Equality operator. Test for equality between two Point4's.
Returns:
Nonzero if the Point4's are equal; otherwise 0.
                                         { 
         return ((p.x==x)&&(p.y==y)&&(p.z==z)&&(p.w==w)); 
     }
int operator!= ( const Point4 p ) const [inline]
                                         { 
         return ((p.x!=x)||(p.y!=y)||(p.z!=z)||(p.w!=w)); 
     }
int Equals ( const Point4 p,
float  epsilon = 1E-6f 
) [inline]
Remarks:
Compares this Point4 and the specified one to see if the x, y, z and w values are within plus or minus the specified tolerance.
Parameters:
const Point4& p

The point to compare.

float epsilon = 1E-6f

The tolerance to use in the comparison.
Returns:
Nonzero if the points are 'equal'; otherwise zero.
Operators:
                                                        {
    return (fabs(p.x - x) <= epsilon && fabs(p.y - y) <= epsilon
            && fabs(p.z - z) <= epsilon && fabs(p.w - w) <= epsilon);
    }
Point4& Unify ( )
float LengthUnify ( )
Point4 operator- ( const Point4 b ) const [inline]
Remarks:
Subtracts a Point4 from a Point4.
Returns:
A Point4 that is the difference between two Point4s.
                                                     {
   return(Point4(x-b.x,y-b.y,z-b.z, w-b.w));
   }
Point4 operator+ ( const Point4 b ) const [inline]
Remarks:
Adds a Point4 to a Point4.
Returns:
A Point4 that is the sum of two Point4s.
                                                     {
   return(Point4(x+b.x,y+b.y,z+b.z, w+b.w));
   }
Point4 operator/ ( const Point4 b ) const [inline]
Remarks:
Divides a Point4 by a Point4 element by element.
Returns:
A Point4 resulting from dividing a Point4 by a Point4 element by element.
                                                     {
   assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f && b.w != 0.0f);
   return Point4(x/b.x,y/b.y,z/b.z,w/b.w);
   }
Point4 operator* ( const Point4 b ) const [inline]
Remarks:
Multiplies a Point4 by a Point4 element by element.

(x*x, y*y, z*z, w*w).
Returns:
A Point4 resulting from the multiplication of a Point4 and a Point4.
                                                     {  
   return Point4(x*b.x, y*b.y, z*b.z,w*b.w); 
   }
float operator% ( const Point4 b ) const [inline]
                                                    {
   return (x*b.x + y*b.y + z*b.z + w*b.w);
}

Member Data Documentation

float x
float y
float z
float w
const Point4 Origin [static]
const Point4 XAxis [static]
const Point4 YAxis [static]
const Point4 ZAxis [static]
const Point4 WAxis [static]

Point4 Point4 Point4 Point4 Point4 Point4 Point4 Point4 Point4 Point4
Point4 Point4 Point4 Point4 Point4 Point4 Point4 Point4 Point4 Point4