Public Member Functions | Public Attributes | Static Public Attributes

Point3 Class Reference

This reference page is linked to from the following overview topics: Lesson 4: Animation Controllers, Lesson 6: Parameter Blocks, Parameter Types, Parameter Tags, Spinner and Slider Control Types, Getting and Setting Parameter Block Values, Computing Face Normals, Computing Vertex Normals, Vertex Color Information, Matrix Fundamentals, Rotation, Scaling, Object Offset Transformation, Creating Primitive NURBS Objects, Principal Classes for Materials and Textures, Texture Coordinates, Controllers, Keyframe Data Access Classes and Methods, Main Physique Export API Elements, IK Concepts, The Enhanced 3ds Max .NET SDK.


Search for all occurrences

Detailed Description

See also:
Class IPoint3, Class DPoint3, Class Matrix3.

Description:
This class describes a 3D point using float 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.

This class is also frequently used to simply store three floating point values that may not represent a point. For example, a color value where x=red, y=green, and z=blue. For color, the range of values is 0.0 to 1.0, where 0 is 0 and 1.0 is 255. All methods are implemented by the system.

Note: In 3ds Max, all vectors are assumed to be row vectors. Under this assumption, multiplication of a vector with a matrix can be written either way (Matrix*Vector or Vector*Matrix), for ease of use, and the result is the same -- the (row) vector transformed by the matrix.
Data Members:
float x, y, z;

The x, y and z components of the point.

static const Point3 Origin;

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

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

static const Point3 XAxis;

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

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

static const Point3 YAxis;

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

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

static const Point3 ZAxis;

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

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

#include <point3.h>

Inheritance diagram for Point3:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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

Public Attributes

float  x
float  y
float  z

Static Public Attributes

static const Point3  Origin
static const Point3  XAxis
static const Point3  YAxis
static const Point3  ZAxis

Constructor & Destructor Documentation

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

Member Function Documentation

float& operator[] ( int  i ) [inline]
Remarks:
Allows access to x, y and z using the subscript operator.
Returns:
An value for i of 0 will return x, 1 will return y, 2 will return z.
                            { 
         return (&x)[i];
     }     
const float& operator[] ( int  i ) const [inline]
Remarks:
Allows access to x, y and z using the subscript operator.
Returns:
An value for i of 0 will return x, 1 will return y, 2 will return z.
                                        { 
         return (&x)[i]; 
     }  
operator float * ( ) [inline]
Remarks:
Conversion function. Returns the address of the Point3.x
                     { 
         return(&x); 
     }
Point3 operator- ( ) const [inline]
Remarks:
Unary - operator. Negates x, y and z.
                            { 
         return(Point3(-x,-y,-z)); 
     } 
Point3 operator+ ( ) const [inline]
Remarks:
Unary +. Returns the Point3.
                            { 
         return *this; 
     }
float Length ( ) const [inline]
Remarks:
Returns the 'Length' of this point (vector). This is:

sqrt(v.x*v.x+v.y*v.y+v.z*v.z)
                                  {  
   return (float)sqrt(x*x+y*y+z*z);
   }
float FLength ( ) const [inline]
Remarks:
Returns the 'Length' of this point (vector) using a faster assembly language implementation for square root. This is:

Sqrt(v.x*v.x+v.y*v.y+v.z*v.z)
                                   { 
   return Sqrt(x*x+y*y+z*z);
   }
float LengthSquared ( ) const [inline]
Remarks:
The 'Length' squared of this point. This is v.x*v.x+v.y*v.y+v.z*v.z.
                                         { 
   return (x*x+y*y+z*z);
   }
int MaxComponent ( ) const
int MinComponent ( ) const
Point3 Normalize ( ) const
Point3 FNormalize ( ) const
Point3 & operator-= ( const Point3 a ) [inline]
Remarks:
Subtracts a Point3 from this Point3.
                                                 {  
   x -= a.x;   y -= a.y;   z -= a.z;
   return *this;
   }
Point3 & operator+= ( const Point3 a ) [inline]
Remarks:
Adds a Point3 to this Point3.
                                                 {
   x += a.x;   y += a.y;   z += a.z;
   return *this;
   }
Point3 & operator*= ( float  f ) [inline]
Remarks:
Multiplies this Point3 by a floating point value.
                                         {
   x *= f;   y *= f; z *= f;
   return *this;
   }
Point3 & operator/= ( float  f ) [inline]
Remarks:
Divides this Point3 by a floating point value.
                                         { 
   x /= f;  y /= f;  z /= f;  
   return *this; 
   }
Point3 & operator*= ( const Point3 a ) [inline]
Remarks:
Element-by-element multiplication of two Point3s:

(x*x, y*y, z*z).
                                                 { 
   x *= a.x;   y *= a.y;   z *= a.z;   
   return *this; 
   }
Point3 & Set ( float  X,
float  Y,
float  Z 
) [inline]
                                                    {
    x = X;
    y = Y;
    z = Z;
    return *this;
    }
int operator== ( const Point3 p ) const [inline]
Remarks:
Equality operator. Test for equality between two Point3's.
Returns:
Nonzero if the Point3's are equal; otherwise 0.
                                         { 
         return ((p.x==x)&&(p.y==y)&&(p.z==z)); 
     }
int operator!= ( const Point3 p ) const [inline]
                                         { 
         return ((p.x!=x)||(p.y!=y)||(p.z!=z)); 
     }
int Equals ( const Point3 p,
float  epsilon = 1E-6f 
) const
Point3& Unify ( )
float LengthUnify ( )
Point3 operator- ( const Point3 b ) const [inline]
Remarks:
Subtracts a Point3 from a Point3.
                                                     {
   return(Point3(x-b.x,y-b.y,z-b.z));
   }
Point3 operator+ ( const Point3 b ) const [inline]
Remarks:
Adds a Point3 to a Point3.
                                                     {
   return(Point3(x+b.x,y+b.y,z+b.z));
   }
Point3 operator/ ( const Point3 b ) const [inline]
Remarks:
Divides a Point3 by a Point3 element by element.
                                                     {
   assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f);
   return Point3(x/b.x,y/b.y,z/b.z);
   }
Point3 operator* ( const Point3 b ) const [inline]
Remarks:
Multiplies a Point3 by a Point3 element by element.

(x*x, y*y, z*z).
                                                     {  
   return Point3(x*b.x, y*b.y, z*b.z); 
   }
Point3 operator^ ( const Point3 ) const
Remarks:
The cross product of two Point3's (vectors).
Returns:
The cross product of two Point3's.
float operator% ( const Point3 b ) const [inline]
                                                    {
   return (x*b.x + y*b.y + z*b.z);
   }

Member Data Documentation

float x
float y
float z
const Point3 Origin [static]
const Point3 XAxis [static]
const Point3 YAxis [static]
const Point3 ZAxis [static]

Point3 Point3 Point3 Point3 Point3 Point3 Point3 Point3 Point3 Point3
Point3 Point3 Point3 Point3 Point3 Point3 Point3 Point3 Point3 Point3