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

class DPoint3 Description: This class describes a 3D point using double precision x, y and z coordinates. More...

#include <dpoint3.h>

Public Member Functions

 DPoint3 ()=default
 Initializes all vector components to zero.
 
constexpr DPoint3 (const DPoint3 &)=default
 
constexpr DPoint3 (DPoint3 &&)=default
 
DPoint3operator= (const DPoint3 &)=default
 
DPoint3operator= (DPoint3 &&)=default
 
constexpr DPoint3 (double X, double Y, double Z)
 Constructor.
 
constexpr DPoint3 (const double af[3])
 Constructor.
 
constexpr DPoint3 (const Point3 &p)
 
constexpr DPoint3operator= (const Point3 &p)
 
double & operator[] (int i)
 const for (0,0,1)
 
const double & operator[] (int i) const
 Allows access to x, y and z using the subscript operator.
 
constexpr operator double * ()
 Conversion function.
 
constexpr operator const double * () const
 
constexpr operator Point3 () const
 Convert DPoint3 to Point3.
 
constexpr DPoint3 operator- () const
 Unary - operator.
 
constexpr DPoint3 operator+ () const
 Unary +.
 
constexpr DPoint3operator-= (const DPoint3 &p)
 Subtracts a DPoint3 from this DPoint3.
 
constexpr DPoint3operator+= (const DPoint3 &p)
 Adds a DPoint3 to this DPoint3.
 
constexpr DPoint3operator*= (const DPoint3 &p)
 Member-wise multiplication of two vectors.
 
DPoint3operator/= (const DPoint3 &p)
 Member-wise, in-place division of this vector.
 
constexpr DPoint3operator+= (double f)
 
constexpr DPoint3operator-= (double f)
 
constexpr DPoint3operator*= (double f)
 Each element of this DPoint3 is multiplied by the specified double.
 
DPoint3operator/= (double f)
 Each element of this DPoint3 is divided by the specified double.
 
constexpr DPoint3 operator- (const DPoint3 &p) const
 Subtracts a DPoint3 from a DPoint3.
 
constexpr DPoint3 operator+ (const DPoint3 &p) const
 Adds a DPoint3 to a DPoint3.
 
DPoint3 operator/ (const DPoint3 &p) const
 
DPoint3 operator* (const DPoint3 &p) const
 Member-wise multiplication of two vectors: (x*x, y*y, z*z)
 
constexpr double LengthSquared () const
 The 'Length' squared of this point.
 
double Length () const
 Returns the 'Length' of this point (vector)
 
DPoint3 Normalize () const
 Returns unit vector in the same direction as this point.
 
DPoint3Unify ()
 in place normalize
 
double LengthUnify ()
 
int MaxComponent () const
 
int MinComponent () const
 
constexpr bool operator== (const DPoint3 &p) const
 Equality operator.
 
constexpr bool operator!= (const DPoint3 &p) const
 Equality operator.
 
bool Equals (const DPoint3 &p, double epsilon=1E-6) const
 
constexpr double DotProd (const DPoint3 &p) const
 
constexpr double operator% (const DPoint3 &p) const
 
constexpr DPoint3 CrossProd (const DPoint3 &p) const
 Computes the cross product of this DPoint3 and the specified DPoint3.
 
constexpr DPoint3 operator^ (const DPoint3 &p) const
 

Public Attributes

double x = 0.0
 
double y = 0.0
 
double z = 0.0
 

Static Public Attributes

static const DPoint3 Origin
 
static const DPoint3 XAxis
 const for (0,0,0)
 
static const DPoint3 YAxis
 const for (1,0,0)
 
static const DPoint3 ZAxis
 const for (0,1,0)
 

Detailed Description

class DPoint3 Description: This class describes a 3D point using double precision 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. All methods are implemented by the system. Data Members: double x,y,z;

Constructor & Destructor Documentation

◆ DPoint3() [1/6]

DPoint3 ( )
default

Initializes all vector components to zero.

◆ DPoint3() [2/6]

constexpr DPoint3 ( const DPoint3 )
constexprdefault

◆ DPoint3() [3/6]

constexpr DPoint3 ( DPoint3 &&  )
constexprdefault

◆ DPoint3() [4/6]

constexpr DPoint3 ( double  X,
double  Y,
double  Z 
)
inlineconstexpr

Constructor.

x, y, and z are initialized to the values specified.

39: x(X), y(Y), z(Z) {}
double z
Definition: dpoint3.h:29
double y
Definition: dpoint3.h:28
double x
Definition: dpoint3.h:27

◆ DPoint3() [5/6]

constexpr DPoint3 ( const double  af[3])
inlineconstexpr

Constructor.

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

42: x(af[0]), y(af[1]), z(af[2]) {}

◆ DPoint3() [6/6]

constexpr DPoint3 ( const Point3 p)
inlineconstexpr
44: x(p.x), y(p.y), z(p.z) {}
float y
Definition: point3.h:57
float x
Definition: point3.h:56
float z
Definition: point3.h:58

Member Function Documentation

◆ operator=() [1/3]

DPoint3 & operator= ( const DPoint3 )
default

◆ operator=() [2/3]

DPoint3 & operator= ( DPoint3 &&  )
default

◆ operator=() [3/3]

constexpr DPoint3 & operator= ( const Point3 p)
inlineconstexpr
46 {
47 x = p.x;
48 y = p.y;
49 z = p.z;
50 return *this;
51 }

◆ operator[]() [1/2]

double & operator[] ( int  i)
inline

const for (0,0,1)

Allows access to x, y and z using the subscript operator.

Returns
An index of 0 will return x, 1 will return y, 2 will return z.
62 {
63 assert((i >= 0) && (i <= 2));
64 return (&x)[i];
65 }
#define assert(expr)
Definition: assert1.h:82

◆ operator[]() [2/2]

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

Allows access to x, y and z using the subscript operator.

Returns
An index of 0 will return x, 1 will return y, 2 will return z.
69 {
70 assert((i >= 0) && (i <= 2));
71 return (&x)[i];
72 }

◆ operator double *()

constexpr operator double * ( )
inlineconstexpr

Conversion function.

Returns the address of the DPoint3.x

77 {
78 return &x;
79 }

◆ operator const double *()

constexpr operator const double * ( ) const
inlineconstexpr
81 {
82 return &x;
83 }

◆ operator Point3()

constexpr operator Point3 ( ) const
inlineconstexpr

Convert DPoint3 to Point3.

86 {
87 return Point3(x, y, z);
88 }
Definition: point3.h:54

◆ operator-() [1/2]

constexpr DPoint3 operator- ( ) const
inlineconstexpr

Unary - operator.

Negates both x, y and z.

93 {
94 return DPoint3(-x, -y, -z);
95 }
DPoint3()=default
Initializes all vector components to zero.

◆ operator+() [1/2]

constexpr DPoint3 operator+ ( ) const
inlineconstexpr

Unary +.

Returns the point unaltered.

98 {
99 return *this;
100 }

◆ operator-=() [1/2]

constexpr DPoint3 & operator-= ( const DPoint3 p)
inlineconstexpr

Subtracts a DPoint3 from this DPoint3.

105 {
106 x -= p.x;
107 y -= p.y;
108 z -= p.z;
109 return *this;
110 }

◆ operator+=() [1/2]

constexpr DPoint3 & operator+= ( const DPoint3 p)
inlineconstexpr

Adds a DPoint3 to this DPoint3.

113 {
114 x += p.x;
115 y += p.y;
116 z += p.z;
117 return *this;
118 }

◆ operator*=() [1/2]

constexpr DPoint3 & operator*= ( const DPoint3 p)
inlineconstexpr

Member-wise multiplication of two vectors.

121 {
122 x *= p.x;
123 y *= p.y;
124 z *= p.z;
125 return *this;
126 }

◆ operator/=() [1/2]

DPoint3 & operator/= ( const DPoint3 p)
inline

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

129 {
130 assert(p.x != 0 && p.y != 0 && p.z != 0);
131 x /= p.x;
132 y /= p.y;
133 z /= p.z;
134 return *this;
135 }

◆ operator+=() [2/2]

constexpr DPoint3 & operator+= ( double  f)
inlineconstexpr
Remarks
Adds floating point value to this DPoint3.
139 {
140 x += f;
141 y += f;
142 z += f;
143 return *this;
144 }

◆ operator-=() [2/2]

constexpr DPoint3 & operator-= ( double  f)
inlineconstexpr
Remarks
Subtracts floating point value from this DPoint3.
147 {
148 return *this += -f;
149 }

◆ operator*=() [2/2]

constexpr DPoint3 & operator*= ( double  f)
inlineconstexpr

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

153 {
154 x *= f;
155 y *= f;
156 z *= f;
157 return *this;
158 }

◆ operator/=() [2/2]

DPoint3 & operator/= ( double  f)
inline

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

162 {
163 assert(f != 0);
164 return *this *= (1.0 / f);
165 }

◆ operator-() [2/2]

constexpr DPoint3 operator- ( const DPoint3 p) const
inlineconstexpr

Subtracts a DPoint3 from a DPoint3.

170 {
171 return DPoint3(x - p.x, y - p.y, z - p.z);
172 }

◆ operator+() [2/2]

constexpr DPoint3 operator+ ( const DPoint3 p) const
inlineconstexpr

Adds a DPoint3 to a DPoint3.

175 {
176 return Point3(x + p.x, y + p.y, z + p.z);
177 }

◆ operator/()

DPoint3 operator/ ( const DPoint3 p) const
inline
Remarks
Divides a DPoint3 by a DPoint3 element by element.
180 {
181 assert(p.x != 0 && p.y != 0 && p.z != 0);
182 return DPoint3(x / p.x, y / p.y, z / p.z);
183 }

◆ operator*()

DPoint3 operator* ( const DPoint3 p) const
inline

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

186 {
187 return DPoint3(x * p.x, y * p.y, z * p.z);
188 }

◆ LengthSquared()

constexpr double LengthSquared ( ) const
inlineconstexpr

The 'Length' squared of this point.

192 {
193 return x * x + y * y + z * z;
194 }

◆ Length()

double Length ( ) const
inline

Returns the 'Length' of this point (vector)

197 {
198 return sqrt(LengthSquared());
199 }
constexpr double LengthSquared() const
The 'Length' squared of this point.
Definition: dpoint3.h:191

◆ Normalize()

DPoint3 Normalize ( ) const

Returns unit vector in the same direction as this point.

◆ Unify()

DPoint3 & Unify ( )

in place normalize

◆ LengthUnify()

double LengthUnify ( )

◆ MaxComponent()

int MaxComponent ( ) const
Returns
The largest axis

◆ MinComponent()

int MinComponent ( ) const
Returns
The smallest axis

◆ operator==()

constexpr bool operator== ( const DPoint3 p) const
inlineconstexpr

Equality operator.

Test for equality between two DPoint3's.

Returns
true if the DPoint3's are equal.
217 {
218 return (p.x == x) && (p.y == y) && (p.z == z);
219 }

◆ operator!=()

constexpr bool operator!= ( const DPoint3 p) const
inlineconstexpr

Equality operator.

Test for nonequality between two DPoint3's.

Returns
true if the DPoint3's are not equal.
223 {
224 return !(*this == p);
225 }

◆ Equals()

bool Equals ( const DPoint3 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

◆ DotProd()

constexpr double DotProd ( const DPoint3 p) const
inlineconstexpr
Remarks
The dot product of two DPoint3's (vectors).
232 {
233 return x * p.x + y * p.y + z * p.z;
234 }

◆ operator%()

constexpr double operator% ( const DPoint3 p) const
inlineconstexpr
236 {
237 return DotProd(p);
238 }
constexpr double DotProd(const DPoint3 &p) const
Definition: dpoint3.h:231

◆ CrossProd()

constexpr DPoint3 CrossProd ( const DPoint3 p) const
inlineconstexpr

Computes the cross product of this DPoint3 and the specified DPoint3.

242 {
243 return DPoint3(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x);
244 }

◆ operator^()

constexpr DPoint3 operator^ ( const DPoint3 p) const
inlineconstexpr
246 {
247 return CrossProd(p);
248 }
constexpr DPoint3 CrossProd(const DPoint3 &p) const
Computes the cross product of this DPoint3 and the specified DPoint3.
Definition: dpoint3.h:241

Member Data Documentation

◆ x

double x = 0.0

◆ y

double y = 0.0

◆ z

double z = 0.0

◆ Origin

const DPoint3 Origin
static

◆ XAxis

const DPoint3 XAxis
static

const for (0,0,0)

◆ YAxis

const DPoint3 YAxis
static

const for (1,0,0)

◆ ZAxis

const DPoint3 ZAxis
static

const for (0,1,0)