3ds Max C++ API Reference
Point4 Class Reference

#include <point4.h>

+ Inheritance diagram for Point4:

Public Member Functions

 Point4 ()=default
 Initializes vector components to zero. More...
 
 Point4 (const Point4 &)=default
 
 Point4 (Point4 &&)=default
 
Point4operator= (const Point4 &)=default
 
Point4operator= (Point4 &&)=default
 
 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 float af[4])
 
 Point4 (const AColor &c)
 
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
 
Point4operator-= (const Point4 &)
 
Point4operator+= (const Point4 &)
 
Point4operator*= (float)
 
Point4operator/= (float)
 
Point4operator*= (const Point4 &)
 
Point4Set (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)
 
Point4Unify ()
 
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 = 0.f
 
float y = 0.f
 
float z = 0.f
 
float w = 0.f
 

Static Public Attributes

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

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

Constructor & Destructor Documentation

◆ Point4() [1/9]

Point4 ( )
default

Initializes vector components to zero.

◆ Point4() [2/9]

Point4 ( const Point4 )
default

◆ Point4() [3/9]

Point4 ( Point4 &&  )
default

◆ Point4() [4/9]

Point4 ( float  X,
float  Y,
float  Z,
float  W 
)
inline
Remarks
Constructor. x, y, z and w are initialized to the values specified.
62  : x(X)
63  , y(Y)
64  , z(Z)
65  , w(W)
66  {
67  }
float w
Definition: point4.h:50
float y
Definition: point4.h:48
float x
Definition: point4.h:47
float z
Definition: point4.h:49

◆ Point4() [5/9]

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).
71  : Point4(float(X), float(Y), float(Z), float(W))
72  {
73  }
Point4()=default
Initializes vector components to zero.

◆ Point4() [6/9]

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).
77  : Point4(float(X), float(Y), float(Z), float(W))
78  {
79  }

◆ Point4() [7/9]

Point4 ( const Point3 a,
float  W = 0.0f 
)
inline
Remarks
Constructor. x, y, z and w are initialized to the specified Point3 and W.
83  {
84  x = a.x;
85  y = a.y;
86  z = a.z;
87  w = W;
88  }
float y
Definition: point3.h:61
float x
Definition: point3.h:60
float z
Definition: point3.h:62

◆ Point4() [8/9]

Point4 ( const float  af[4])
inline
Remarks
Constructor. x, y, z and w are initialized to af[0], af[1], af[2] and af[3] respectively.
92  {
93  x = af[0];
94  y = af[1];
95  z = af[2];
96  w = af[3];
97  }

◆ Point4() [9/9]

Point4 ( const AColor c)
explicit

Member Function Documentation

◆ operator=() [1/2]

Point4& operator= ( const Point4 )
default

◆ operator=() [2/2]

Point4& operator= ( Point4 &&  )
default

◆ operator[]() [1/2]

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.
112  {
113  DbgAssert((i >= 0) && (i <= 3));
114  return (&x)[i];
115  }
#define DbgAssert(expr)
Definition: assert1.h:82

◆ operator[]() [2/2]

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.
120  {
121  DbgAssert((i >= 0) && (i <= 3));
122  return (&x)[i];
123  }

◆ operator float *()

operator float * ( )
inline
Remarks
Conversion function. Returns the address of the Point4.x
128  {
129  return (&x);
130  }

◆ operator-() [1/2]

Point4 operator- ( ) const
inline
Remarks
Unary - operator. Negates x, y, z and w.
135  {
136  return (Point4(-x, -y, -z, -w));
137  }

◆ operator+() [1/2]

Point4 operator+ ( ) const
inline
Remarks
Unary +. Returns the Point4.
140  {
141  return *this;
142  }

◆ Length()

float Length ( ) const
inline
244 {
245  return (float)sqrt(x * x + y * y + z * z + w * w);
246 }

◆ FLength()

float FLength ( ) const
inline
249 {
250  return Sqrt(x * x + y * y + z * z + w * w);
251 }
float Sqrt(float arg)
Definition: gfloat.h:43

◆ LengthSquared()

float LengthSquared ( ) const
inline
254 {
255  return (x * x + y * y + z * z + w * w);
256 }

◆ MaxComponent()

int MaxComponent ( ) const

◆ MinComponent()

int MinComponent ( ) const

◆ Normalize()

Point4 Normalize ( ) const

◆ FNormalize()

Point4 FNormalize ( ) const

◆ operator-=()

Point4 & operator-= ( const Point4 a)
inline
Remarks
Subtracts a Point4 from this Point4.
Returns
A Point4 that is the difference between two Point4s.
274 {
275  x -= a.x;
276  y -= a.y;
277  z -= a.z;
278  w -= a.w;
279 
280  return *this;
281 }

◆ operator+=()

Point4 & operator+= ( const Point4 a)
inline
Remarks
Adds a Point4 to this Point4.
Returns
A Point4 that is the sum of two Point4s.
284 {
285  x += a.x;
286  y += a.y;
287  z += a.z;
288  w += a.w;
289  return *this;
290 }

◆ operator*=() [1/2]

Point4 & operator*= ( float  f)
inline
Remarks
Multiplies this Point4 by a floating point value.
Returns
A Point4 multiplied by a float.
293 {
294  x *= f;
295  y *= f;
296  z *= f;
297  w *= f;
298 
299  return *this;
300 }

◆ operator/=()

Point4 & operator/= ( float  f)
inline
Remarks
Divides this Point4 by a floating point value.
Returns
A Point4 divided by a float.
303 {
304  DbgAssert(f != 0.0f);
305  if (f == 0.0f)
306  f = .000001f;
307  float invF = 1.0f / f; // Mimic 2019 behavior
308  x *= invF;
309  y *= invF;
310  z *= invF;
311  w *= invF;
312 
313  return *this;
314 }

◆ operator*=() [2/2]

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.
317 {
318  x *= a.x;
319  y *= a.y;
320  z *= a.z;
321  w *= a.w;
322 
323  return *this;
324 }

◆ Set()

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.
327 {
328  x = X;
329  y = Y;
330  z = Z;
331  w = W;
332 
333  return *this;
334 }

◆ operator==()

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

◆ operator!=()

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

◆ Equals()

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:
393 {
394  return (fabs(p.x - x) <= epsilon && fabs(p.y - y) <= epsilon && fabs(p.z - z) <= epsilon &&
395  fabs(p.w - w) <= epsilon);
396 }

◆ Unify()

Point4& Unify ( )

◆ LengthUnify()

float LengthUnify ( )

◆ operator-() [2/2]

Point4 operator- ( const Point4 b) const
inline
Remarks
Subtracts a Point4 from a Point4.
Returns
A Point4 that is the difference between two Point4s.
337 {
338  return (Point4(x - b.x, y - b.y, z - b.z, w - b.w));
339 }

◆ operator+() [2/2]

Point4 operator+ ( const Point4 b) const
inline
Remarks
Adds a Point4 to a Point4.
Returns
A Point4 that is the sum of two Point4s.
342 {
343  return (Point4(x + b.x, y + b.y, z + b.z, w + b.w));
344 }

◆ operator/()

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.
347 {
348  assert(b.x != 0.0f && b.y != 0.0f && b.z != 0.0f && b.w != 0.0f);
349  return Point4(x / b.x, y / b.y, z / b.z, w / b.w);
350 }
#define assert(expr)
Definition: assert1.h:81

◆ operator*()

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.
353 {
354  return Point4(x * b.x, y * b.y, z * b.z, w * b.w);
355 }

◆ operator%()

float operator% ( const Point4 b) const
inline
388 {
389  return (x * b.x + y * b.y + z * b.z + w * b.w);
390 }

Member Data Documentation

◆ x

float x = 0.f

◆ y

float y = 0.f

◆ z

float z = 0.f

◆ w

float w = 0.f

◆ Origin

const Point4 Origin
static

◆ XAxis

const Point4 XAxis
static

◆ YAxis

const Point4 YAxis
static

◆ ZAxis

const Point4 ZAxis
static

◆ WAxis

const Point4 WAxis
static