3ds Max C++ API Reference
Loading...
Searching...
No Matches
DPoint2 Class Reference

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

#include <dpoint2.h>

Public Member Functions

constexpr DPoint2 ()=default
 
constexpr DPoint2 (const DPoint2 &)=default
 
constexpr DPoint2 (DPoint2 &&)=default
 
DPoint2operator= (const DPoint2 &)=default
 
DPoint2operator= (DPoint2 &&)=default
 
constexpr DPoint2 (double X, double Y)
 
constexpr DPoint2 (const Point2 &a)
 
constexpr DPoint2 (const double af[2])
 
constexpr DPoint2operator= (const Point2 &a)
 Assign a Point2 to this DPoint2.
 
double & operator[] (int i)
 const for (0,1)
 
const double & operator[] (int i) const
 
constexpr operator double * ()
 Conversion function.
 
constexpr operator const double * () const
 
constexpr operator Point2 ()
 Convert DPoint2 to Point2.
 
constexpr DPoint2 operator- () const
 Unary - operator.
 
constexpr DPoint2 operator+ () const
 Unary +.
 
constexpr DPoint2operator-= (const DPoint2 &a)
 Subtracts a DPoint2 from this DPoint2.
 
constexpr DPoint2operator+= (const DPoint2 &a)
 Adds a DPoint2 to this DPoint2.
 
constexpr DPoint2operator*= (const DPoint2 &a)
 Member-wise multiplication of two vectors: (x*x, y*y)
 
DPoint2operator/= (const DPoint2 &a)
 Member-wise division of two vectors.
 
constexpr DPoint2operator+= (double a)
 Each element of this DPoint2 is increased by the specified double.
 
constexpr DPoint2operator-= (double a)
 Each element of this DPoint2 is decreased by the specified double.
 
constexpr DPoint2operator*= (double a)
 Each element of this DPoint2 is multiplied by the specified double.
 
DPoint2operator/= (double a)
 Each element of this DPoint2 is divided by the specified double.
 
constexpr DPoint2 operator- (const DPoint2 &a) const
 Subtracts a DPoint2 from a DPoint2.
 
constexpr DPoint2 operator+ (const DPoint2 &a) const
 Adds a DPoint2 to a DPoint2.
 
constexpr DPoint2 operator* (const DPoint2 &a) const
 Member-wise multiplication of two vectors: (x*x, y*y)
 
DPoint2 operator/ (const DPoint2 &a) const
 Member-wise division of two vectors:
 
constexpr double DotProd (const DPoint2 &a) const
 Returns the dot product of two DPoint2s.
 
constexpr double operator% (const DPoint2 &a) const
 Returns the dot product of two DPoint2s.
 
constexpr double LengthSquared () const
 The 'Length' squared of this point.
 
double Length () const
 Returns the 'Length' of this point (vector).
 
DPoint2Unify ()
 In place normalize.
 
double LengthUnify ()
 
int MaxComponent () const
 
int MinComponent () const
 
DPoint2 Normalize () const
 Returns a unit vector.
 
constexpr bool operator== (const DPoint2 &p) const
 
constexpr bool operator!= (const DPoint2 &p) const
 
bool Equals (const DPoint2 &p, double epsilon=1E-6) const
 

Public Attributes

double x = 0.0
 
double y = 0.0
 

Static Public Attributes

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

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]

constexpr DPoint2 ( )
constexprdefault

◆ DPoint2() [2/6]

constexpr DPoint2 ( const DPoint2 )
constexprdefault

◆ DPoint2() [3/6]

constexpr DPoint2 ( DPoint2 &&  )
constexprdefault

◆ DPoint2() [4/6]

constexpr DPoint2 ( double  X,
double  Y 
)
inlineconstexpr
Remarks
Constructor. Data members are initialized to X and Y.
36: x(X), y(Y) {}
double y
Definition: dpoint2.h:27
double x
Definition: dpoint2.h:26

◆ DPoint2() [5/6]

constexpr DPoint2 ( const Point2 a)
inlineconstexpr
Remarks
Constructor. Data members are initialized to a.x and a.y.
38: x(a.x), y(a.y) {}
float a
Definition: texutil.h:51

◆ DPoint2() [6/6]

constexpr DPoint2 ( const double  af[2])
inlineconstexpr
Remarks
Constructor. Data members are initialized as x = af[0] and y = af[1].
40: x(af[0]), y(af[1]) {}

Member Function Documentation

◆ operator=() [1/3]

DPoint2 & operator= ( const DPoint2 )
default

◆ operator=() [2/3]

DPoint2 & operator= ( DPoint2 &&  )
default

◆ operator=() [3/3]

constexpr DPoint2 & operator= ( const Point2 a)
inlineconstexpr

Assign a Point2 to this DPoint2.

43 {
44 x = a.x;
45 y = a.y;
46 return *this;
47 }

◆ operator[]() [1/2]

double & operator[] ( int  i)
inline

const for (0,1)

Remarks
Allows access to x, y using the subscript operator.
Returns
An index of 0 will return x, 1 will return y.
58 {
59 assert((i == 0) || (i == 1));
60 return (i == 0) ? x : y;
61 }
#define assert(expr)
Definition: assert1.h:82

◆ operator[]() [2/2]

const double & operator[] ( int  i) const
inline
63 {
64 assert((i == 0) || (i == 1));
65 return (i == 0) ? x : y;
66 }

◆ operator double *()

constexpr operator double * ( )
inlineconstexpr

Conversion function.

Returns the address of the DPoint2.x

Returns
a pointer to the x component.
73 {
74 return &x;
75 }

◆ operator const double *()

constexpr operator const double * ( ) const
inlineconstexpr
77 {
78 return &x;
79 }

◆ operator Point2()

constexpr operator Point2 ( )
inlineconstexpr

Convert DPoint2 to Point2.

83 {
84 return Point2(x, y);
85 }
Definition: point2.h:38

◆ operator-() [1/2]

constexpr DPoint2 operator- ( ) const
inlineconstexpr

Unary - operator.

Negates both x and y

91 {
92 return DPoint2(-x, -y);
93 }
constexpr DPoint2()=default

◆ operator+() [1/2]

constexpr DPoint2 operator+ ( ) const
inlineconstexpr

Unary +.

Returns this point unaltered.

97 {
98 return *this;
99 }

◆ operator-=() [1/2]

constexpr DPoint2 & operator-= ( const DPoint2 a)
inlineconstexpr

Subtracts a DPoint2 from this DPoint2.

Parameters
athe value to subtract from this DPoint2
Returns
the resulting DPoint2
105 {
106 x -= a.x;
107 y -= a.y;
108 return *this;
109 }

◆ operator+=() [1/2]

constexpr DPoint2 & operator+= ( const DPoint2 a)
inlineconstexpr

Adds a DPoint2 to this DPoint2.

Parameters
athe value to add to this DPoint2
Returns
the resulting DPoint2
115 {
116 x += a.x;
117 y += a.y;
118 return *this;
119 }

◆ operator*=() [1/2]

constexpr DPoint2 & operator*= ( const DPoint2 a)
inlineconstexpr

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

Parameters
athe multiplier
Returns
the resulting DPoint2
125 {
126 x *= a.x;
127 y *= a.y;
128 return *this;
129 }

◆ operator/=() [1/2]

DPoint2 & operator/= ( const DPoint2 a)
inline

Member-wise division of two vectors.

Parameters
athe multiplier
Returns
the resulting DPoint2
135 {
136 assert(a.x != 0.0 && a.y != 0.0);
137 x /= a.x;
138 y /= a.y;
139 return *this;
140 }

◆ operator+=() [2/2]

constexpr DPoint2 & operator+= ( double  a)
inlineconstexpr

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

144 {
145 x += a;
146 y += a;
147 return *this;
148 }

◆ operator-=() [2/2]

constexpr DPoint2 & operator-= ( double  a)
inlineconstexpr

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

152 {
153 return *this += -a;
154 }

◆ operator*=() [2/2]

constexpr DPoint2 & operator*= ( double  a)
inlineconstexpr

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

Parameters
athe multiplier
Returns
the resulting DPoint2
161 {
162 x *= a;
163 y *= a;
164 return *this;
165 }

◆ operator/=() [2/2]

DPoint2 & operator/= ( double  a)
inline

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

Parameters
athe divisor
Returns
the resulting DPoint2
172 {
173 assert(a != 0.0);
174 return *this *= (1.0 / a);
175 }

◆ operator-() [2/2]

constexpr DPoint2 operator- ( const DPoint2 a) const
inlineconstexpr

Subtracts a DPoint2 from a DPoint2.

Parameters
athe value to subtract from this DPoint2
Returns
the resulting DPoint2
183 {
184 return DPoint2(x - a.x, y - a.y);
185 }

◆ operator+() [2/2]

constexpr DPoint2 operator+ ( const DPoint2 a) const
inlineconstexpr

Adds a DPoint2 to a DPoint2.

Parameters
athe value to add to this DPoint2
Returns
the resulting DPoint2
191 {
192 return DPoint2(x + a.x, y + a.y);
193 }

◆ operator*()

constexpr DPoint2 operator* ( const DPoint2 a) const
inlineconstexpr

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

Parameters
athe multiplier
Returns
the resulting DPoint2
199 {
200 return DPoint2(x * a.x, y * a.y);
201 }

◆ operator/()

DPoint2 operator/ ( const DPoint2 a) const
inline

Member-wise division of two vectors:

Parameters
athe multiplier
Returns
the resulting DPoint2
207 {
208 assert(a.x != 0.0 && a.y != 0.0);
209 return DPoint2(x / a.x, y / a.y);
210 }

◆ DotProd()

constexpr double DotProd ( const DPoint2 a) const
inlineconstexpr

Returns the dot product of two DPoint2s.

214 {
215 return x * a.x + y * a.y;
216 }

◆ operator%()

constexpr double operator% ( const DPoint2 a) const
inlineconstexpr

Returns the dot product of two DPoint2s.

219 {
220 return DotProd(a);
221 }
constexpr double DotProd(const DPoint2 &a) const
Returns the dot product of two DPoint2s.
Definition: dpoint2.h:213

◆ LengthSquared()

constexpr double LengthSquared ( ) const
inlineconstexpr

The 'Length' squared of this point.

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

Returns
the length value
226 {
227 return x * x + y * y;
228 }

◆ Length()

double Length ( ) const
inline

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

This is:

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

Returns
the length value
234 {
235 return sqrt(LengthSquared());
236 }
constexpr double LengthSquared() const
The 'Length' squared of this point.
Definition: dpoint2.h:225

◆ Unify()

DPoint2 & Unify ( )

In place normalize.

Returns
the normalized value

◆ LengthUnify()

double LengthUnify ( )

◆ MaxComponent()

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

◆ MinComponent()

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

◆ Normalize()

DPoint2 Normalize ( ) const

Returns a unit vector.

This is a DPoint2 with each component divided by the point Length().

Returns
the unit vector for the specified DPoint2

◆ operator==()

constexpr bool operator== ( const DPoint2 p) const
inlineconstexpr
Remarks
Equality operator. Compares two Point2's.
256 {
257 return p.x == x && p.y == y;
258 }

◆ operator!=()

constexpr bool operator!= ( const DPoint2 p) const
inlineconstexpr
260 {
261 return !(*this == p);
262 }

◆ Equals()

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

Member Data Documentation

◆ x

double x = 0.0

◆ y

double y = 0.0

◆ Origin

const DPoint2 Origin
static

◆ XAxis

const DPoint2 XAxis
static

const for (0,0)

◆ YAxis

const DPoint2 YAxis
static

const for (1,0)