Public Member Functions | Public Attributes | Static Public Attributes

Point2 Class Reference

This reference page is linked to from the following overview topics: IK Concepts.


Search for all occurrences

Detailed Description

See also:
Class IPoint2.

Description:
This class describes a 2D point using float x and y coordinates. Methods are provided to add and subtract points, multiply and divide by scalars, normalize and compute the dot product of two Point2s. All methods are implemented by the system.
Data Members:
float x,y;

The x and y components of the point.

static const Point2 Origin;

This data member is available in release 3.0 and later only.

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

static const Point2 XAxis;

This data member is available in release 3.0 and later only.

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

static const Point2 YAxis;

This data member is available in release 3.0 and later only.

This is equivalent to Point2(0.0f, 1.0f);
Constructors

#include <point2.h>

Inheritance diagram for Point2:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  Point2 ()
  Point2 (float X, float Y)
  Point2 (double X, double Y)
  Point2 (int X, int Y)
  Point2 (const Point2 &a)
  Point2 (float af[2])
float &  operator[] (int i)
const float &  operator[] (int i) const
  operator float * ()
Point2  operator- () const
Point2  operator+ () const
float  Length () const
int  MaxComponent () const
int  MinComponent () const
Point2  Normalize () const
Point2 operator-= (const Point2 &)
Point2 operator+= (const Point2 &)
Point2 operator*= (float)
Point2 operator/= (float)
Point2 Set (float X, float Y)
Point2  operator- (const Point2 &) const
Point2  operator+ (const Point2 &) const
float  DotProd (const Point2 &) const
float  operator* (const Point2 &) const
int  operator== (const Point2 &p) const
int  operator!= (const Point2 &p) const
int  Equals (const Point2 &p, float epsilon=1E-6f)
Point2 Unify ()
float  LengthUnify ()

Public Attributes

float  x
float  y

Static Public Attributes

static const Point2  Origin
static const Point2  XAxis
static const Point2  YAxis

Constructor & Destructor Documentation

Point2 ( ) [inline]
Remarks:
Constructor. No initialization is performed by this constructor.
{}
Point2 ( float  X,
float  Y 
) [inline]
Remarks:
Constructor. Data members are initialized to X and Y.
                              { 
        x = X; y = Y;  
    }
Point2 ( double  X,
double  Y 
) [inline]
Remarks:
Constructor. Data members are initialized to X and Y cast as floats.
                                { 
        x = (float)X; y = (float)Y;  
    }
Point2 ( int  X,
int  Y 
) [inline]
Remarks:
Constructor. Data members are initialized to X and Y cast as floats.
                          { 
        x = (float)X; y = (float)Y;  
    }
Point2 ( const Point2 a ) [inline]
Remarks:
Constructor. Data members are initialized to a.x and a.y.
                            { 
        x = a.x; y = a.y; 
    } 
Point2 ( float  af[2] ) [inline]
Remarks:
Constructor. Data members are initialized as x = af[0] and y = af[1].
                        { 
        x = af[0]; y = af[1]; 
    }

Member Function Documentation

float& operator[] ( int  i ) [inline]
Remarks:
Allows access to x, y using the subscript operator.
Returns:
A value for i of 0 will return x, 1 will return y.
                             { 
        return (&x)[i]; 
    }     
const float& operator[] ( int  i ) const [inline]
Remarks:
Allows access to x, y using the subscript operator.
Returns:
A value for i of 0 will return x, 1 will return y.
                                         { 
        return (&x)[i]; 
    }  
operator float * ( ) [inline]
Remarks:
Returns the address of the Point2.x
                      { 
        return(&x); 
    }
Point2 operator- ( ) const [inline]
Remarks:
Unary -. Negates both x and y.
Returns:
A Point2 with -x, -y.
                             { 
        return(Point2(-x,-y)); 
    } 
Point2 operator+ ( ) const [inline]
Remarks:
Unary +. Returns the point unaltered.
Returns:
Returns the Point2 unaltered.
                             { 
        return *this; 
    }
float Length ( ) const [inline]
Remarks:
Returns the length of the point. This is sqrt(v.x*v.x+v.y*v.y);
                                  { 
    return (float)sqrt(x*x+y*y);
    }
int MaxComponent ( ) const
Remarks:
This method returns the component with the maximum absolute value.
Returns:
0 for X, 1 for Y, 2 for Z.
int MinComponent ( ) const
Remarks:
This method returns the component with the minimum absolute value.
Returns:
0 for X, 1 for Y, 2 for Z.
Point2 Normalize ( ) const
Remarks:
This method returns a normalized version of this Point2. This method is more accurate than *this/Length() (internal computations are done in double precision).
Point2 & operator-= ( const Point2 a ) [inline]
Remarks:
Subtracts a Point2 from this Point2.
Returns:
A Point2 that is the difference between two Point2s.
                                                 {  
    x -= a.x;   y -= a.y;  
    return *this;
    }
Point2 & operator+= ( const Point2 a ) [inline]
Remarks:
Adds a Point2 to this Point2.
Returns:
A Point2 that is the sum of two Point2's.
                                                 {
    x += a.x;   y += a.y;  
    return *this;
    }
Point2 & operator*= ( float  f ) [inline]
Remarks:
Multiplies this Point2 by a floating point value.
Returns:
A Point2 multiplied by a float.
                                         {
    x *= f;   y *= f;   
    return *this;
    }
Point2 & operator/= ( float  f ) [inline]
Remarks:
Divides this Point2 by a floating point value.
Returns:
A Point2 divided by a float.
                                         { 
    x /= f; y /= f;     
    return *this; 
    }
Point2 & Set ( float  X,
float  Y 
) [inline]
Remarks:
Sets the x and y coordinate to the values passed and returns a reference to this Point2.
Parameters:
float X

The new x value.

float Y

The new y value.
Returns:
A reference to this Point2.
                                           {
    x = X; y = Y;
    return *this;
    }
Point2 operator- ( const Point2 b ) const [inline]
Remarks:
Subtracts a Point2 from a Point2.
Returns:
A Point2 that is the difference between two Point2's.
                                                    {
    return(Point2(x-b.x,y-b.y));
    }
Point2 operator+ ( const Point2 b ) const [inline]
Remarks:
Adds a Point2 to a Point2.
Returns:
The sum of two Point2's.
                                                     {
    return(Point2(x+b.x,y+b.y));
    }
float DotProd ( const Point2 b ) const [inline]
Remarks:
Returns the dot product of two Point2's. This is the sum of both x values multiplied together and both y values multiplied together.
                                                 {
    return(x*b.x+y*b.y);
    }
float operator* ( const Point2 b ) const [inline]
Remarks:
Returns the dot product of two Point2's. This is the sum of both x values multiplied together and both y values multiplied together.
                                                   {
    return(x*b.x+y*b.y);
    }
int operator== ( const Point2 p ) const [inline]
Remarks:
Equality operator. Compares two Point2's.
Returns:
Nonzero if the Point2's are equal; otherwise 0.
{ return (x == p.x && y == p.y); }
int operator!= ( const Point2 p ) const [inline]
{ return ( (x != p.x) || (y != p.y) ); }
int Equals ( const Point2 p,
float  epsilon = 1E-6f 
)
Remarks:
Compares this Point2 and the specified one to see if the x and y values are within plus or minus the specified tolerance.
Parameters:
const Point2& 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.
Point2& Unify ( )
Remarks:
This method is used to unify (or normalize) this Point2 (in place) and return the result. Internal computations are done in double precision.
float LengthUnify ( )
Remarks:
This method is used to unify (or normalize) this Point2 (in place) and return the previous length. Internal computations are done in double precision.

Member Data Documentation

float x
float y
const Point2 Origin [static]
const Point2 XAxis [static]
const Point2 YAxis [static]

Point2 Point2 Point2 Point2 Point2 Point2 Point2 Point2 Point2 Point2
Point2 Point2 Point2 Point2 Point2 Point2 Point2 Point2 Point2 Point2