3ds Max C++ API Reference
DPoint2 Class Reference

Description: This class describes a 2D point using double precision x and y coordinates. More...

#include <dpoint2.h>

+ Inheritance diagram for DPoint2:

Public Member Functions

 DPoint2 ()=default
 Constructor. More...
 
 DPoint2 (const DPoint2 &)=default
 
 DPoint2 (DPoint2 &&)=default
 
DPoint2operator= (const DPoint2 &)=default
 
DPoint2operator= (DPoint2 &&)=default
 
 DPoint2 (double X, double Y)
 Constructor. More...
 
 DPoint2 (const Point2 &a)
 Constructor. More...
 
 DPoint2 (const double af[2])
 Constructor. More...
 
double & operator[] (int i)
 Allows access to x and y using the subscript operator. More...
 
const double & operator[] (int i) const
 Allows access to x and y using the subscript operator. More...
 
 operator double * ()
 Conversion function. More...
 
 operator Point2 ()
 Convert DPoint2 to Point2. More...
 
DPoint2 operator- () const
 Unary - operator. More...
 
DPoint2 operator+ () const
 Unary +. More...
 
DPoint2operator= (const Point2 &a)
 Assignment operator. More...
 
DPoint2operator-= (const DPoint2 &a)
 Subtracts a DPoint2 from this DPoint2. More...
 
DPoint2operator+= (const DPoint2 &a)
 Adds a DPoint2 to this DPoint2. More...
 
DPoint2operator*= (const DPoint2 &a)
 Member-wise multiplication of two vectors: (x*x, y*y) More...
 
DPoint2operator*= (double a)
 Each element of this DPoint2 is multiplied by the specified double. More...
 
DPoint2operator/= (double a)
 Each element of this DPoint2 is divided by the specified double. More...
 
DPoint2 operator- (const DPoint2 &a) const
 Subtracts a DPoint2 from a DPoint2. More...
 
DPoint2 operator+ (const DPoint2 &a) const
 Adds a DPoint2 to a DPoint2. More...
 
DPoint2 operator* (const DPoint2 &a) const
 Member-wise multiplication of two vectors: (x*x, y*y) More...
 
double Length () const
 Returns the 'Length' of this point (vector). More...
 
double LengthSquared () const
 The 'Length' squared of this point. More...
 
DPoint2Unify ()
 In place normalize. More...
 
int MaxComponent () const
 The largest axis. More...
 
int MinComponent () const
 The smallest axis. More...
 
int operator== (const DPoint2 &p) const
 Equality operator. More...
 
int operator!= (const DPoint2 &p) const
 Equality operator. More...
 

Public Attributes

double x = 0.0
 
double y = 0.0
 

Static Public Attributes

static const DPoint2 Origin
 const for (0,0) More...
 
static const DPoint2 XAxis
 const for (1,0) More...
 
static const DPoint2 YAxis
 const for (0,1) More...
 

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

Description: This class describes a 2D point using double precision x and y coordinates.

Methods are provided to add and subtract points, multiply and divide by scalars, and element by element multiply and divide two points. All methods are implemented by the system.

Constructor & Destructor Documentation

◆ DPoint2() [1/6]

DPoint2 ( )
default

Constructor.

Initializes all vector components to zero.

◆ DPoint2() [2/6]

DPoint2 ( const DPoint2 )
default

◆ DPoint2() [3/6]

DPoint2 ( DPoint2 &&  )
default

◆ DPoint2() [4/6]

DPoint2 ( double  X,
double  Y 
)
inline

Constructor.

x and y are initialized to the values specified.

42  {
43  x = X;
44  y = Y;
45  }
double y
Definition: dpoint2.h:27
double x
Definition: dpoint2.h:26

◆ DPoint2() [5/6]

DPoint2 ( const Point2 a)
inline

Constructor.

x and y are initialized to the Point2 specified.

Parameters
avalue used to initialize x and y components
51  {
52  x = a.x;
53  y = a.y;
54  }
float y
Definition: point2.h:49
float x
Definition: point2.h:48

◆ DPoint2() [6/6]

DPoint2 ( const double  af[2])
inline

Constructor.

x and y are initialized to. af[0] and af[1] respectively.

Parameters
aftwo-element array to initialize x and y components
60  {
61  x = af[0];
62  y = af[1];
63  }

Member Function Documentation

◆ operator=() [1/3]

DPoint2& operator= ( const DPoint2 )
default

◆ operator=() [2/3]

DPoint2& operator= ( DPoint2 &&  )
default

◆ operator[]() [1/2]

double& operator[] ( int  i)
inline

Allows access to x and y using the subscript operator.

Parameters
iindex of component to return (0 or 1)
Returns
An index of 0 will return x, 1 will return y.
71  {
72  DbgAssert((i >= 0) && (i <= 1));
73  return (i == 0) ? x : y;
74  }
#define DbgAssert(expr)
Definition: assert1.h:82

◆ operator[]() [2/2]

const double& operator[] ( int  i) const
inline

Allows access to x and y using the subscript operator.

Parameters
iindex of component to return (0 or 1)
Returns
An index of 0 will return x, 1 will return y.
80  {
81  DbgAssert((i >= 0) && (i <= 1));
82  return (i == 0) ? x : y;
83  }

◆ operator double *()

operator double * ( )
inline

Conversion function.

Returns the address of the DPoint2.x

Returns
a pointer to the x component.
90  {
91  return (&x);
92  }

◆ operator Point2()

operator Point2 ( )
inline

Convert DPoint2 to Point2.

Returns
the value as a Point2
97  {
98  return Point2(x, y);
99  }
Definition: point2.h:44

◆ operator-() [1/2]

DPoint2 operator- ( ) const
inline

Unary - operator.

Negates both x and y

Returns
the resulting DPoint2
106  {
107  return (DPoint2(-x, -y));
108  }
DPoint2()=default
Constructor.

◆ operator+() [1/2]

DPoint2 operator+ ( ) const
inline

Unary +.

Returns the point unaltered.

Returns
the resulting DPoint2
113  {
114  return *this;
115  }

◆ operator=() [3/3]

DPoint2& operator= ( const Point2 a)
inline

Assignment operator.

Parameters
athe Point2 to assign to this DPoint2
Returns
the resulting DPoint2
121  {
122  x = a.x;
123  y = a.y;
124  return *this;
125  }

◆ operator-=()

DPoint2 & operator-= ( const DPoint2 a)
inline

Subtracts a DPoint2 from this DPoint2.

Parameters
athe value to subtract from this DPoint2
Returns
the resulting DPoint2
277 {
278  x -= a.x;
279  y -= a.y;
280  return *this;
281 }

◆ operator+=()

DPoint2 & operator+= ( const DPoint2 a)
inline

Adds a DPoint2 to this DPoint2.

Parameters
athe value to add to this DPoint2
Returns
the resulting DPoint2
284 {
285  x += a.x;
286  y += a.y;
287  return *this;
288 }

◆ operator*=() [1/2]

DPoint2 & operator*= ( const DPoint2 a)
inline

Member-wise multiplication of two vectors: (x*x, y*y)

Parameters
athe multiplier
Returns
the resulting DPoint2
291 {
292  x *= rhs.x;
293  y *= rhs.y;
294  return *this;
295 }

◆ operator*=() [2/2]

DPoint2 & operator*= ( double  a)
inline

Each element of this DPoint2 is multiplied by the specified double.

Parameters
athe multiplier
Returns
the resulting DPoint2
298 {
299  x *= f;
300  y *= f;
301  return *this;
302 }

◆ operator/=()

DPoint2 & operator/= ( double  a)
inline

Each element of this DPoint2 is divided by the specified double.

Parameters
athe divisor
Returns
the resulting DPoint2
305 {
306  DbgAssert(f != 0.0);
307  double invF = 1.0 / f; // Mimic 2019 behavior
308  x *= invF;
309  y *= invF;
310  return *this;
311 }

◆ operator-() [2/2]

DPoint2 operator- ( const DPoint2 a) const
inline

Subtracts a DPoint2 from a DPoint2.

Parameters
athe value to subtract from this DPoint2
Returns
the resulting DPoint2
314 {
315  return (DPoint2(x - b.x, y - b.y));
316 }

◆ operator+() [2/2]

DPoint2 operator+ ( const DPoint2 a) const
inline

Adds a DPoint2 to a DPoint2.

Parameters
athe value to add to this DPoint2
Returns
the resulting DPoint2
319 {
320  return (DPoint2(x + b.x, y + b.y));
321 }

◆ operator*()

DPoint2 operator* ( const DPoint2 a) const
inline

Member-wise multiplication of two vectors: (x*x, y*y)

Parameters
athe multiplier
Returns
the resulting DPoint2
324 {
325  return DPoint2(x * b.x, y * b.y);
326 }

◆ Length()

double Length ( ) const

Returns the 'Length' of this point (vector).

This is:

sqrt(v.x*v.x+v.y*v.y).

Returns
the length value

◆ LengthSquared()

double LengthSquared ( ) const

The 'Length' squared of this point.

This is v.x*v.x+v.y*v.y.

Returns
the length value

◆ Unify()

DPoint2& Unify ( )

In place normalize.

Returns
the normalized value

◆ MaxComponent()

int MaxComponent ( ) const

The largest axis.

Returns
the largest axis (0 = x, 1 = y)

◆ MinComponent()

int MinComponent ( ) const

The smallest axis.

Returns
the smallest axis (0 = x, 1 = y)

◆ operator==()

int operator== ( const DPoint2 p) const
inline

Equality operator.

Test for equality between two DPoint2's.

Parameters
pthe value to compare
Returns
Nonzero if the DPoint2's are equal; otherwise 0.
199  {
200  return ((p.x == x) && (p.y == y));
201  }

◆ operator!=()

int operator!= ( const DPoint2 p) const
inline

Equality operator.

Test for nonequality between two DPoint2's.

Parameters
pthe value to compare
Returns
Nonzero if the DPoint2's are not equal; otherwise 0.
207  {
208  return ((p.x != x) || (p.y != y));
209  }

Member Data Documentation

◆ x

double x = 0.0

◆ y

double y = 0.0

◆ Origin

const DPoint2 Origin
static

const for (0,0)

◆ XAxis

const DPoint2 XAxis
static

const for (1,0)

◆ YAxis

const DPoint2 YAxis
static

const for (0,1)