Point3 Class Reference

Point3 Class Reference
+ Related help topics:

#include <point3.h>

Class 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);
+ Inheritance diagram for Point3:

Public Member Functions

 Point3 ()
 Initializes all vector components to zero. More...
 
 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 (const 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
 
Point3operator-= (const Point3 &)
 
Point3operator+= (const Point3 &)
 
Point3operator*= (float)
 
Point3operator/= (float)
 
Point3operator*= (const Point3 &)
 
Point3Set (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
 
Point3Unify ()
 
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
 
Point2 XY () const
 Converts this Point3 into a Point2 using the X and Y components. Useful for passing a Point3 where a Point2 is expected. More...
 

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
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

Point3 ( )
inline

Initializes all vector components to zero.

58 : x(0.0f), y(0.0f), z(0.0f) { }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3 ( float  X,
float  Y,
float  Z 
)
inline
Remarks
Constructor. x, y, and z are initialized to the values specified.
60  {
61  x = X; y = Y; z = Z;
62  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3 ( double  X,
double  Y,
double  Z 
)
inline
Remarks
Constructor. x, y, and z are initialized to the specified values (cast as floats).
64  {
65  x = (float)X; y = (float)Y; z = (float)Z;
66  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3 ( int  X,
int  Y,
int  Z 
)
inline
Remarks
Constructor. x, y, and z are initialized to the specified values (cast as floats).
68  {
69  x = (float)X; y = (float)Y; z = (float)Z;
70  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3 ( const Point3 a)
inline
Remarks
Constructor. x, y, and z are initialized to the specified Point3.
72  {
73  x = a.x; y = a.y; z = a.z;
74  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3 ( const float  af[3])
inline
Remarks
Constructor. x, y, and z are initialized to af[0], af[1], and af[2] respectively.
77  {
78  x = af[0]; y = af[1]; z = af[2];
79  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55

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.
90  {
91  DbgAssert((i >= 0) && (i <= 2));
92  return (&x)[i];
93  }
float x
Definition: point3.h:55
#define DbgAssert(expr)
Definition: assert1.h:72
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.
97  {
98  DbgAssert((i >= 0) && (i <= 2));
99  return (&x)[i];
100  }
float x
Definition: point3.h:55
#define DbgAssert(expr)
Definition: assert1.h:72
operator float * ( )
inline
Remarks
Conversion function. Returns the address of the Point3.x
104  {
105  return(&x);
106  }
float x
Definition: point3.h:55
Point3 operator- ( ) const
inline
Remarks
Unary - operator. Negates x, y and z.
110  {
111  return(Point3(-x,-y,-z));
112  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3()
Initializes all vector components to zero.
Definition: point3.h:58
Point3 operator+ ( ) const
inline
Remarks
Unary +. Returns the Point3.
114  {
115  return *this;
116  }
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)
236  {
237  return (float)sqrt(x*x+y*y+z*z);
238  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
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)
240  {
241  return Sqrt(x*x+y*y+z*z);
242  }
float y
Definition: point3.h:55
float Sqrt(float arg)
Definition: gfloat.h:76
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline float LengthSquared ( ) const
Remarks
The 'Length' squared of this point. This is v.x*v.x+v.y*v.y+v.z*v.z.
244  {
245  return (x*x+y*y+z*z);
246  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
int MaxComponent ( ) const
int MinComponent ( ) const
Point3 Normalize ( ) const
Point3 FNormalize ( ) const
__forceinline Point3 & operator-= ( const Point3 a)
inline
Remarks
Subtracts a Point3 from this Point3.
260  {
261  x -= a.x; y -= a.y; z -= a.z;
262  return *this;
263  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline Point3 & operator+= ( const Point3 a)
inline
Remarks
Adds a Point3 to this Point3.
265  {
266  x += a.x; y += a.y; z += a.z;
267  return *this;
268  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline Point3 & operator*= ( float  f)
inline
Remarks
Multiplies this Point3 by a floating point value.
270  {
271  x *= f; y *= f; z *= f;
272  return *this;
273  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline Point3 & operator/= ( float  f)
inline
Remarks
Divides this Point3 by a floating point value.
275  {
276  x /= f; y /= f; z /= f;
277  return *this;
278  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline Point3 & operator*= ( const Point3 a)
inline
Remarks
Element-by-element multiplication of two Point3s:

(x*x, y*y, z*z).
280  {
281  x *= a.x; y *= a.y; z *= a.z;
282  return *this;
283  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline Point3 & Set ( float  X,
float  Y,
float  Z 
)
inline
285  {
286  x = X;
287  y = Y;
288  z = Z;
289  return *this;
290  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
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.
152  {
153  return ((p.x==x)&&(p.y==y)&&(p.z==z));
154  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
int operator!= ( const Point3 p) const
inline
155  {
156  return ((p.x!=x)||(p.y!=y)||(p.z!=z));
157  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
int Equals ( const Point3 p,
float  epsilon = 1E-6f 
) const
Point3& Unify ( )
float LengthUnify ( )
__forceinline Point3 operator- ( const Point3 b) const
inline
Remarks
Subtracts a Point3 from a Point3.
292  {
293  return(Point3(x-b.x,y-b.y,z-b.z));
294  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3()
Initializes all vector components to zero.
Definition: point3.h:58
__forceinline Point3 operator+ ( const Point3 b) const
inline
Remarks
Adds a Point3 to a Point3.
296  {
297  return(Point3(x+b.x,y+b.y,z+b.z));
298  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3()
Initializes all vector components to zero.
Definition: point3.h:58
__forceinline Point3 operator/ ( const Point3 b) const
inline
Remarks
Divides a Point3 by a Point3 element by element.
300  {
301  assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f);
302  return Point3(x/b.x,y/b.y,z/b.z);
303  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3()
Initializes all vector components to zero.
Definition: point3.h:58
#define assert(expr)
Definition: assert1.h:71
__forceinline Point3 operator* ( const Point3 b) const
inline
Remarks
Multiplies a Point3 by a Point3 element by element.

(x*x, y*y, z*z).
305  {
306  return Point3(x*b.x, y*b.y, z*b.z);
307  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
Point3()
Initializes all vector components to zero.
Definition: point3.h:58
Point3 operator^ ( const Point3 ) const
Remarks
The cross product of two Point3's (vectors).
Returns
The cross product of two Point3's.
__forceinline float operator% ( const Point3 b) const
inline
309  {
310  return (x*b.x + y*b.y + z*b.z);
311  }
float y
Definition: point3.h:55
float z
Definition: point3.h:55
float x
Definition: point3.h:55
__forceinline Point2 XY ( ) const

Converts this Point3 into a Point2 using the X and Y components. Useful for passing a Point3 where a Point2 is expected.

314 {
315  return Point2(x, y);
316 }
float y
Definition: point3.h:55
float x
Definition: point3.h:55
Definition: point2.h:43

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