3ds Max C++ API Reference
Point4 Class Reference

#include <point4.h>

Public Member Functions

 Point4 ()=default
 Initializes vector components to zero. More...
 
constexpr Point4 (const Point4 &)=default
 
constexpr Point4 (Point4 &&)=default
 
Point4operator= (const Point4 &)=default
 
Point4operator= (Point4 &&)=default
 
constexpr Point4 (float X, float Y, float Z, float W)
 
constexpr Point4 (double X, double Y, double Z, double W)
 
constexpr Point4 (int X, int Y, int Z, int W)
 
constexpr Point4 (const Point3 &a, float W=0.f)
 
constexpr Point4 (const float af[4])
 
 Point4 (const AColor &c)
 
float & operator[] (int i)
 
const float & operator[] (int i) const
 
constexpr operator float * ()
 
constexpr operator const float * () const
 
constexpr Point4 operator- () const
 
constexpr Point4 operator+ () const
 
constexpr float LengthSquared () const
 
float Length () const
 
float FLength () const
 
int MaxComponent () const
 
int MinComponent () const
 
Point4 Normalize () const
 
Point4 FNormalize () const
 
constexpr Point4operator-= (const Point4 &a)
 
constexpr Point4operator+= (const Point4 &a)
 
constexpr Point4operator*= (const Point4 &a)
 
Point4operator/= (const Point4 &a)
 
constexpr Point4operator+= (float f)
 
constexpr Point4operator-= (float f)
 
constexpr Point4operator*= (float f)
 
Point4operator/= (float f)
 
constexpr Point4Set (float X, float Y, float Z, float W)
 
constexpr bool operator== (const Point4 &p) const
 
constexpr bool operator!= (const Point4 &p) const
 
bool Equals (const Point4 &p, float epsilon=1E-6f) const
 
Point4Unify ()
 
float LengthUnify ()
 
constexpr Point4 operator- (const Point4 &a) const
 
constexpr Point4 operator+ (const Point4 &a) const
 
Point4 operator/ (const Point4 &a) const
 
constexpr Point4 operator* (const Point4 &a) const
 
constexpr float DotProd (const Point4 &a) const
 
constexpr float operator% (const Point4 &a) 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
 

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]

constexpr Point4 ( const Point4 )
constexprdefault

◆ Point4() [3/9]

constexpr Point4 ( Point4 &&  )
constexprdefault

◆ Point4() [4/9]

constexpr Point4 ( float  X,
float  Y,
float  Z,
float  W 
)
inlineconstexpr
Remarks
Constructor. x, y, z and w are initialized to the values specified.
56 : x(X), y(Y), z(Z), w(W) {}
float w
Definition: point4.h:46
float y
Definition: point4.h:44
float x
Definition: point4.h:43
float z
Definition: point4.h:45

◆ Point4() [5/9]

constexpr Point4 ( double  X,
double  Y,
double  Z,
double  W 
)
inlineconstexpr
Remarks
Constructor. x, y, z and w are initialized to the specified values (cast as floats).
58 : Point4(float(X), float(Y), float(Z), float(W)) {}
Point4()=default
Initializes vector components to zero.

◆ Point4() [6/9]

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

◆ Point4() [7/9]

constexpr Point4 ( const Point3 a,
float  W = 0.f 
)
inlineconstexpr
Remarks
Constructor. x, y, z and w are initialized to the specified Point3 and W.
62 : x(a.x), y(a.y), z(a.z), w(W) {}
float y
Definition: point3.h:57
float x
Definition: point3.h:56
float z
Definition: point3.h:58

◆ Point4() [8/9]

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

◆ 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.
79  {
80  assert(i >= 0 && i <= 3);
81  return (&x)[i];
82  }
#define assert(expr)
Definition: assert1.h:81

◆ 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.
87  {
88  assert(i >= 0 && i <= 3);
89  return (&x)[i];
90  }

◆ operator float *()

constexpr operator float * ( )
inlineconstexpr
Remarks
Conversion function. Returns the address of the Point4.x
95  {
96  return &x;
97  }

◆ operator const float *()

constexpr operator const float * ( ) const
inlineconstexpr
99  {
100  return &x;
101  }

◆ operator-() [1/2]

constexpr Point4 operator- ( ) const
inlineconstexpr
Remarks
Unary - operator. Negates x, y, z and w.
106  {
107  return Point4(-x, -y, -z, -w);
108  }

◆ operator+() [1/2]

constexpr Point4 operator+ ( ) const
inlineconstexpr
Remarks
Unary +. Returns the Point4.
111  {
112  return *this;
113  }

◆ LengthSquared()

constexpr float LengthSquared ( ) const
inlineconstexpr
117  {
118  return x * x + y * y + z * z + w * w;
119  }

◆ Length()

float Length ( ) const
inline
121  {
122  return (float)sqrt((double)LengthSquared());
123  }
constexpr float LengthSquared() const
Definition: point4.h:116

◆ FLength()

float FLength ( ) const
inline
125  {
126  return sqrt(LengthSquared());
127  }

◆ MaxComponent()

int MaxComponent ( ) const

◆ MinComponent()

int MinComponent ( ) const

◆ Normalize()

Point4 Normalize ( ) const

◆ FNormalize()

Point4 FNormalize ( ) const

◆ operator-=() [1/2]

constexpr Point4& operator-= ( const Point4 a)
inlineconstexpr
Remarks
Subtracts a Point4 from this Point4.
Returns
A Point4 that is the difference between two Point4s.
137  {
138  x -= a.x;
139  y -= a.y;
140  z -= a.z;
141  w -= a.w;
142  return *this;
143  }

◆ operator+=() [1/2]

constexpr Point4& operator+= ( const Point4 a)
inlineconstexpr
Remarks
Adds a Point4 to this Point4.
Returns
A Point4 that is the sum of two Point4s.
147  {
148  x += a.x;
149  y += a.y;
150  z += a.z;
151  w += a.w;
152  return *this;
153  }

◆ operator*=() [1/2]

constexpr Point4& operator*= ( const Point4 a)
inlineconstexpr
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.
158  {
159  x *= a.x;
160  y *= a.y;
161  z *= a.z;
162  w *= a.w;
163  return *this;
164  }

◆ operator/=() [1/2]

Point4& operator/= ( const Point4 a)
inline
Remarks
Element-by-element division of two Point4s:

(x/x, y/y, z/z, w/w).
Returns
A Point4 element-by-element divided by another Point4.
169  {
170  assert(a.x != 0 && a.y != 0 && a.z != 0 && a.w != 0);
171  x /= a.x;
172  y /= a.y;
173  z /= a.z;
174  w /= a.w;
175  return *this;
176  }

◆ operator+=() [2/2]

constexpr Point4& operator+= ( float  f)
inlineconstexpr
Remarks
Adds floating point value to this Point4.
Returns
A Point4 + a float.
181  {
182  x += f;
183  y += f;
184  z += f;
185  w += f;
186  return *this;
187  }

◆ operator-=() [2/2]

constexpr Point4& operator-= ( float  f)
inlineconstexpr
Remarks
Subtracts a floating point value from this Point4.
Returns
A Point4 - a float.
191  {
192  return *this += -f;
193  }

◆ operator*=() [2/2]

constexpr Point4& operator*= ( float  f)
inlineconstexpr
Remarks
Multiplies this Point4 by a floating point value.
Returns
A Point4 multiplied by a float.
197  {
198  x *= f;
199  y *= f;
200  z *= f;
201  w *= f;
202  return *this;
203  }

◆ operator/=() [2/2]

Point4& operator/= ( float  f)
inline
Remarks
Divides this Point4 by a floating point value.
Returns
A Point4 divided by a float.
207  {
208  assert(f != 0.f);
209  if (f == 0.f)
210  f = .000001f;
211  return *this *= (1.f / f);
212  }

◆ Set()

constexpr Point4& Set ( float  X,
float  Y,
float  Z,
float  W 
)
inlineconstexpr
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.
226  {
227  return *this = { X, Y, Z, W };
228  }
@ 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 Point4 p) const
inlineconstexpr
Remarks
Equality operator. Test for equality between two Point4's.
Returns
Nonzero if the Point4's are equal; otherwise 0.
234  {
235  return p.x == x && p.y == y && p.z == z && p.w == w;
236  }

◆ operator!=()

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

◆ Equals()

bool Equals ( const Point4 p,
float  epsilon = 1E-6f 
) const
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:

◆ Unify()

Point4& Unify ( )

◆ LengthUnify()

float LengthUnify ( )

◆ operator-() [2/2]

constexpr Point4 operator- ( const Point4 a) const
inlineconstexpr
Remarks
Subtracts a Point4 from a Point4.
Returns
A Point4 that is the difference between two Point4s.
262  {
263  return Point4(*this) -= a;
264  }

◆ operator+() [2/2]

constexpr Point4 operator+ ( const Point4 a) const
inlineconstexpr
Remarks
Adds a Point4 to a Point4.
Returns
A Point4 that is the sum of two Point4s.
268  {
269  return Point4(*this) += a;
270  }

◆ operator/()

Point4 operator/ ( const Point4 a) 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.
275  {
276  return Point4(*this) /= a;
277  }

◆ operator*()

constexpr Point4 operator* ( const Point4 a) const
inlineconstexpr
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.
283  {
284  return Point4(*this) *= a;
285  }

◆ DotProd()

constexpr float DotProd ( const Point4 a) const
inlineconstexpr
288  {
289  return x * a.x + y * a.y + z * a.z + w * a.w;
290  }

◆ operator%()

constexpr float operator% ( const Point4 a) const
inlineconstexpr
292  {
293  return DotProd(a);
294  }
constexpr float DotProd(const Point4 &a) const
Definition: point4.h:287

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