3ds Max C++ API Reference
Point3 Class Reference

#include <point3.h>

+ Inheritance diagram for Point3:

Public Member Functions

 Point3 ()=default
 Initializes all vector components to zero. More...
 
 Point3 (const Point3 &)=default
 
 Point3 (Point3 &&)=default
 
Point3operator= (const Point3 &)=default
 
Point3operator= (Point3 &&)=default
 
 Point3 (float X, float Y, float Z)
 
 Point3 (double X, double Y, double Z)
 
 Point3 (int X, int Y, int Z)
 
 Point3 (const float af[3])
 
 Point3 (const Color &c)
 
 Point3 (const AColor &c)
 
 Point3 (const Point4 &p)
 
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. More...
 

Public Attributes

float x = 0.f
 
float y = 0.f
 
float z = 0.f
 

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...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

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);

Constructor & Destructor Documentation

◆ Point3() [1/10]

Point3 ( )
default

Initializes all vector components to zero.

◆ Point3() [2/10]

Point3 ( const Point3 )
default
Remarks
Constructor. x, y, and z are initialized to the specified Point3.

◆ Point3() [3/10]

Point3 ( Point3 &&  )
default
Remarks
Move Constructor. x, y, and z are initialized to the specified Point3.

◆ Point3() [4/10]

Point3 ( float  X,
float  Y,
float  Z 
)
inline
Remarks
Constructor. x, y, and z are initialized to the values specified.
77  {
78  x = X;
79  y = Y;
80  z = Z;
81  }
float y
Definition: point3.h:61
float x
Definition: point3.h:60
float z
Definition: point3.h:62

◆ Point3() [5/10]

Point3 ( double  X,
double  Y,
double  Z 
)
inline
Remarks
Constructor. x, y, and z are initialized to the specified values (cast as floats).
84  {
85  x = static_cast<float>(X);
86  y = static_cast<float>(Y);
87  z = static_cast<float>(Z);
88  }

◆ Point3() [6/10]

Point3 ( int  X,
int  Y,
int  Z 
)
inline
Remarks
Constructor. x, y, and z are initialized to the specified values (cast as floats).
91  {
92  x = static_cast<float>(X);
93  y = static_cast<float>(Y);
94  z = static_cast<float>(Z);
95  }

◆ Point3() [7/10]

Point3 ( const float  af[3])
inline
Remarks
Constructor. x, y, and z are initialized to af[0], af[1], and af[2] respectively.
99  {
100  x = af[0];
101  y = af[1];
102  z = af[2];
103  }

◆ Point3() [8/10]

Point3 ( const Color c)
Remarks
Color Constructor. x = r, y = g, and z = b.

◆ Point3() [9/10]

Point3 ( const AColor c)
Remarks
AColor Constructor. x = r, y = g, and z = b.

◆ Point3() [10/10]

Point3 ( const Point4 p)
Remarks
Point4 Constructor. x = x, y = y, and z = z.

Member Function Documentation

◆ operator=() [1/2]

Point3& operator= ( const Point3 )
default
Remarks
Copy Assignement Operator. x, y, and z are initialized to the specified Point3.

◆ operator=() [2/2]

Point3& operator= ( Point3 &&  )
default
Remarks
Move Assignement Operator. x, y, and z are initialized to the specified Point3.

◆ operator[]() [1/2]

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.
122  {
123  DbgAssert((i >= 0) && (i <= 2));
124  return (&x)[i];
125  }
#define DbgAssert(expr)
Definition: assert1.h:82

◆ operator[]() [2/2]

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.
130  {
131  DbgAssert((i >= 0) && (i <= 2));
132  return (&x)[i];
133  }

◆ operator float *()

operator float * ( )
inline
Remarks
Conversion function. Returns the address of the Point3.x
138  {
139  return (&x);
140  }

◆ operator-() [1/2]

Point3 operator- ( ) const
inline
Remarks
Unary - operator. Negates x, y and z.
145  {
146  return (Point3(-x, -y, -z));
147  }
Point3()=default
Initializes all vector components to zero.

◆ operator+() [1/2]

Point3 operator+ ( ) const
inline
Remarks
Unary +. Returns the Point3.
150  {
151  return *this;
152  }

◆ Length()

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)
282 {
283  return sqrt(x * x + y * y + z * z);
284 }

◆ FLength()

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)
287 {
288  return Sqrt(x * x + y * y + z * z);
289 }
float Sqrt(float arg)
Definition: gfloat.h:43

◆ LengthSquared()

__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.
292 {
293  return (x * x + y * y + z * z);
294 }

◆ MaxComponent()

int MaxComponent ( ) const

◆ MinComponent()

int MinComponent ( ) const

◆ Normalize()

Point3 Normalize ( ) const

◆ FNormalize()

Point3 FNormalize ( ) const

◆ operator-=()

__forceinline Point3 & operator-= ( const Point3 a)
inline
Remarks
Subtracts a Point3 from this Point3.
312 {
313  x -= a.x;
314  y -= a.y;
315  z -= a.z;
316  return *this;
317 }

◆ operator+=()

__forceinline Point3 & operator+= ( const Point3 a)
inline
Remarks
Adds a Point3 to this Point3.
320 {
321  x += a.x;
322  y += a.y;
323  z += a.z;
324  return *this;
325 }

◆ operator*=() [1/2]

__forceinline Point3 & operator*= ( float  f)
inline
Remarks
Multiplies this Point3 by a floating point value.
328 {
329  x *= f;
330  y *= f;
331  z *= f;
332  return *this;
333 }

◆ operator/=()

__forceinline Point3 & operator/= ( float  f)
inline
Remarks
Divides this Point3 by a floating point value.
336 {
337  DbgAssert(f != 0.0f);
338  float invF = 1.0f / f; // Mimic 2019 behavior
339  x *= invF;
340  y *= invF;
341  z *= invF;
342  return *this;
343 }

◆ operator*=() [2/2]

__forceinline Point3 & operator*= ( const Point3 a)
inline
Remarks
Element-by-element multiplication of two Point3s:

(x*x, y*y, z*z).
346 {
347  x *= a.x;
348  y *= a.y;
349  z *= a.z;
350  return *this;
351 }

◆ Set()

__forceinline Point3 & Set ( float  X,
float  Y,
float  Z 
)
inline
354 {
355  x = X;
356  y = Y;
357  z = Z;
358  return *this;
359 }

◆ operator==()

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.
189  {
190  return ((p.x == x) && (p.y == y) && (p.z == z));
191  }

◆ operator!=()

int operator!= ( const Point3 p) const
inline
193  {
194  return ((p.x != x) || (p.y != y) || (p.z != z));
195  }

◆ Equals()

int Equals ( const Point3 p,
float  epsilon = 1E-6f 
) const

◆ Unify()

Point3& Unify ( )

◆ LengthUnify()

float LengthUnify ( )

◆ operator-() [2/2]

__forceinline Point3 operator- ( const Point3 b) const
inline
Remarks
Subtracts a Point3 from a Point3.
362 {
363  return (Point3(x - b.x, y - b.y, z - b.z));
364 }

◆ operator+() [2/2]

__forceinline Point3 operator+ ( const Point3 b) const
inline
Remarks
Adds a Point3 to a Point3.
367 {
368  return (Point3(x + b.x, y + b.y, z + b.z));
369 }

◆ operator/()

__forceinline Point3 operator/ ( const Point3 b) const
inline
Remarks
Divides a Point3 by a Point3 element by element.
372 {
373  assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f);
374  return Point3(x / b.x, y / b.y, z / b.z);
375 }
#define assert(expr)
Definition: assert1.h:81

◆ operator*()

__forceinline Point3 operator* ( const Point3 b) const
inline
Remarks
Multiplies a Point3 by a Point3 element by element.

(x*x, y*y, z*z).
378 {
379  return Point3(x * b.x, y * b.y, z * b.z);
380 }

◆ operator^()

Point3 operator^ ( const Point3 ) const
Remarks
The cross product of two Point3's (vectors).
Returns
The cross product of two Point3's.

◆ operator%()

__forceinline float operator% ( const Point3 b) const
inline
383 {
384  return (x * b.x + y * b.y + z * b.z);
385 }

◆ XY()

__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.

388 {
389  return Point2(x, y);
390 }
Definition: point2.h:44

Member Data Documentation

◆ x

float x = 0.f

◆ y

float y = 0.f

◆ z

float z = 0.f

◆ Origin

const Point3 Origin
static

◆ XAxis

const Point3 XAxis
static

◆ YAxis

const Point3 YAxis
static

◆ ZAxis

const Point3 ZAxis
static