3ds Max C++ API Reference
Point3 Class Reference

#include <point3.h>

Public Member Functions

 Point3 ()=default
 Initializes all vector components to zero. More...
 
constexpr Point3 (const Point3 &)=default
 
constexpr Point3 (Point3 &&)=default
 
Point3operator= (const Point3 &)=default
 
Point3operator= (Point3 &&)=default
 
constexpr Point3 (float X, float Y, float Z)
 
constexpr Point3 (const float af[3])
 
constexpr Point3 (double X, double Y, double Z)
 
constexpr Point3 (int X, int Y, int Z)
 
 Point3 (const Color &c)
 
 Point3 (const AColor &c)
 
 Point3 (const Point4 &p)
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
constexpr operator float * ()
 
constexpr operator const float * () const
 
constexpr Point3 operator- () const
 
constexpr Point3 operator+ () const
 
constexpr float LengthSquared () const
 
float Length () const
 
float FLength () const
 
int MaxComponent () const
 
int MinComponent () const
 
Point3 Normalize () const
 
Point3 FNormalize () const
 
constexpr Point3operator-= (const Point3 &p)
 
constexpr Point3operator+= (const Point3 &p)
 
constexpr Point3operator*= (const Point3 &p)
 
Point3operator/= (const Point3 &p)
 Member-wise, in-place division of this vector. More...
 
constexpr Point3operator+= (float f)
 
constexpr Point3operator-= (float f)
 
constexpr Point3operator*= (float f)
 
Point3operator/= (float f)
 
constexpr Point3Set (float X, float Y, float Z)
 
constexpr bool operator== (const Point3 &p) const
 
constexpr bool operator!= (const Point3 &p) const
 
bool Equals (const Point3 &p, float epsilon=1E-6f) const
 
Point3Unify ()
 
float LengthUnify ()
 
constexpr Point3 operator- (const Point3 &p) const
 
constexpr Point3 operator+ (const Point3 &p) const
 
Point3 operator/ (const Point3 &p) const
 
constexpr Point3 operator* (const Point3 &p) const
 
constexpr float DotProd (const Point3 &p) const
 
constexpr float operator% (const Point3 &p) const
 
constexpr Point3 CrossProd (const Point3 &p) const
 
constexpr Point3 operator^ (const Point3 &p) const
 
constexpr 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
 

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]

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

◆ Point3() [3/10]

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

◆ Point3() [4/10]

constexpr Point3 ( float  X,
float  Y,
float  Z 
)
inlineconstexpr
Remarks
Constructor. x, y, and z are initialized to the values specified.
72 : x(X), y(Y), z(Z) {}
float y
Definition: point3.h:57
float x
Definition: point3.h:56
float z
Definition: point3.h:58

◆ Point3() [5/10]

constexpr Point3 ( const float  af[3])
inlineconstexpr
Remarks
Constructor. x, y, and z are initialized to af[0], af[1], and af[2] respectively.
74 : x(af[0]), y(af[1]), z(af[2]) {}

◆ Point3() [6/10]

constexpr Point3 ( double  X,
double  Y,
double  Z 
)
inlineconstexpr
Remarks
Constructor. x, y, and z are initialized to the specified values (cast as floats).
76 : x(float(X)), y(float(Y)), z(float(Z)) {}

◆ Point3() [7/10]

constexpr Point3 ( int  X,
int  Y,
int  Z 
)
inlineconstexpr
Remarks
Constructor. x, y, and z are initialized to the specified values (cast as floats).
78 : x(float(X)), y(float(Y)), z(float(Z)) {}

◆ 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.
96  {
97  assert((i >= 0) && (i <= 2));
98  return (&x)[i];
99  }
#define assert(expr)
Definition: assert1.h:81

◆ 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.
104  {
105  assert((i >= 0) && (i <= 2));
106  return (&x)[i];
107  }

◆ operator float *()

constexpr operator float * ( )
inlineconstexpr
Remarks
Conversion function. Returns the address of the Point3.x
112  {
113  return &x;
114  }

◆ operator const float *()

constexpr operator const float * ( ) const
inlineconstexpr
116  {
117  return &x;
118  }

◆ operator-() [1/2]

constexpr Point3 operator- ( ) const
inlineconstexpr
Remarks
Unary - operator. Negates x, y and z.
123  {
124  return Point3(-x, -y, -z);
125  }
Point3()=default
Initializes all vector components to zero.

◆ operator+() [1/2]

constexpr Point3 operator+ ( ) const
inlineconstexpr
Remarks
Unary +. Returns the Point3.
128  {
129  return *this;
130  }

◆ LengthSquared()

constexpr float LengthSquared ( ) const
inlineconstexpr
Remarks
The 'Length' squared of this point. This is v.x*v.x+v.y*v.y+v.z*v.z.
136  {
137  return x * x + y * y + z * z;
138  }

◆ Length()

float Length ( ) const
inline
Remarks
Returns the 'Length' of this point (vector).
141  {
142  return (float)sqrt((double)LengthSquared());
143  }
constexpr float LengthSquared() const
Definition: point3.h:135

◆ FLength()

float FLength ( ) const
inline
Remarks
Returns the 'Length' of this point (vector) using float square root.
146  {
147  return (float)sqrt(LengthSquared());
148  }

◆ MaxComponent()

int MaxComponent ( ) const
Remarks
Returns the component with the maximum abs value. 0=x, 1=y, 2=z.

◆ MinComponent()

int MinComponent ( ) const
Remarks
Returns the component with the minimum abs value. 0=x, 1=y, 2=z.

◆ Normalize()

Point3 Normalize ( ) const
Remarks
Normalizes point using float precision

◆ FNormalize()

Point3 FNormalize ( ) const
Remarks
Normalizes point using double precision

◆ operator-=() [1/2]

constexpr Point3& operator-= ( const Point3 p)
inlineconstexpr
Remarks
Subtracts a Point3 from this Point3.
163  {
164  x -= p.x;
165  y -= p.y;
166  z -= p.z;
167  return *this;
168  }

◆ operator+=() [1/2]

constexpr Point3& operator+= ( const Point3 p)
inlineconstexpr
Remarks
Adds a Point3 to this Point3.
171  {
172  x += p.x;
173  y += p.y;
174  z += p.z;
175  return *this;
176  }

◆ operator*=() [1/2]

constexpr Point3& operator*= ( const Point3 p)
inlineconstexpr
Remarks
Element-by-element multiplication of two Point3s
179  {
180  x *= p.x;
181  y *= p.y;
182  z *= p.z;
183  return *this;
184  }

◆ operator/=() [1/2]

Point3& operator/= ( const Point3 p)
inline

Member-wise, in-place division of this vector.

187  {
188  assert(p.x != 0 && p.y != 0 && p.z != 0);
189  x /= p.x;
190  y /= p.y;
191  z /= p.z;
192  return *this;
193  }

◆ operator+=() [2/2]

constexpr Point3& operator+= ( float  f)
inlineconstexpr
Remarks
Adds floating point value to this Point3.
197  {
198  x += f;
199  y += f;
200  z += f;
201  return *this;
202  }

◆ operator-=() [2/2]

constexpr Point3& operator-= ( float  f)
inlineconstexpr
Remarks
Subtracts floating point value from this Point3.
205  {
206  return *this += -f;
207  }

◆ operator*=() [2/2]

constexpr Point3& operator*= ( float  f)
inlineconstexpr
Remarks
Multiplies this Point3 by a floating point value.
210  {
211  x *= f;
212  y *= f;
213  z *= f;
214  return *this;
215  }

◆ operator/=() [2/2]

Point3& operator/= ( float  f)
inline
Remarks
Divides this Point3 by a floating point value.
218  {
219  assert(f != 0);
220  return *this *= (1.f/ f);
221  }

◆ Set()

constexpr Point3& Set ( float  X,
float  Y,
float  Z 
)
inlineconstexpr
224  {
225  x = X;
226  y = Y;
227  z = Z;
228  return *this;
229  }
@ X
Using the X axis as the slice axis.
@ Z
Using the Z axis as the slice axis.
@ Y
Using the Y axis as the slice axis.

◆ operator==()

constexpr bool operator== ( const Point3 p) const
inlineconstexpr
Remarks
Equality operator. Test for equality between two Point3's.
Returns
Nonzero if the Point3's are equal; otherwise 0.
235  {
236  return p.x == x && p.y == y && p.z == z;
237  }

◆ operator!=()

constexpr bool operator!= ( const Point3 p) const
inlineconstexpr
239  {
240  return !(*this == p);
241  }

◆ Equals()

bool Equals ( const Point3 p,
float  epsilon = 1E-6f 
) const
Remarks
Returns true if the absolute difference between point components is less or equal to the given epsilon for each component

◆ Unify()

Point3& Unify ( )

◆ LengthUnify()

float LengthUnify ( )

◆ operator-() [2/2]

constexpr Point3 operator- ( const Point3 p) const
inlineconstexpr
Remarks
Subtracts a Point3 from a Point3.
253  {
254  return Point3(x - p.x, y - p.y, z - p.z);
255  }

◆ operator+() [2/2]

constexpr Point3 operator+ ( const Point3 p) const
inlineconstexpr
Remarks
Adds a Point3 to a Point3.
258  {
259  return Point3(x + p.x, y + p.y, z + p.z);
260  }

◆ operator/()

Point3 operator/ ( const Point3 p) const
inline
Remarks
Divides a Point3 by a Point3 element by element.
263  {
264  assert(p.x != 0 && p.y != 0 && p.z != 0);
265  return Point3(x / p.x, y / p.y, z / p.z);
266  }

◆ operator*()

constexpr Point3 operator* ( const Point3 p) const
inlineconstexpr
Remarks
Multiplies a Point3 by a Point3 element by element.

(x*x, y*y, z*z).
270  {
271  return Point3(x * p.x, y * p.y, z * p.z);
272  }

◆ DotProd()

constexpr float DotProd ( const Point3 p) const
inlineconstexpr
Remarks
The dot product of two Point3's (vectors).
276  {
277  return x * p.x + y * p.y + z * p.z;
278  }

◆ operator%()

constexpr float operator% ( const Point3 p) const
inlineconstexpr
280  {
281  return DotProd(p);
282  }
constexpr float DotProd(const Point3 &p) const
Definition: point3.h:275

◆ CrossProd()

constexpr Point3 CrossProd ( const Point3 p) const
inlineconstexpr
Remarks
The cross product of two Point3's (vectors).
Returns
The cross product of two Point3's.
287  {
288  return Point3(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x);
289  }

◆ operator^()

constexpr Point3 operator^ ( const Point3 p) const
inlineconstexpr
291  {
292  return CrossProd(p);
293  }
constexpr Point3 CrossProd(const Point3 &p) const
Definition: point3.h:286

◆ XY()

constexpr Point2 XY ( ) const
inlineconstexpr

Converts this Point3 into a Point2 using the X and Y components.

Useful for passing a Point3 where a Point2 is expected.

298  {
299  return Point2(x, y);
300  }
Definition: point2.h:38

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