3ds Max C++ API Reference
IPoint2 Class Reference

#include <ipoint2.h>

Public Member Functions

 IPoint2 ()=default
 
constexpr IPoint2 (const IPoint2 &)=default
 
constexpr IPoint2 (IPoint2 &&)=default
 
IPoint2operator= (const IPoint2 &)=default
 
IPoint2operator= (IPoint2 &&)=default
 
constexpr IPoint2 (int X, int Y)
 
constexpr IPoint2 (int af[2])
 
intoperator[] (int i)
 
const intoperator[] (int i) const
 
constexpr operator int * ()
 
constexpr operator const int * () const
 
constexpr IPoint2 operator- () const
 
constexpr IPoint2 operator+ () const
 
constexpr int LengthSquared () const
 
float Length () const
 
int MaxComponent () const
 
int MinComponent () const
 
constexpr IPoint2operator-= (const IPoint2 &a)
 
constexpr IPoint2operator+= (const IPoint2 &a)
 
constexpr IPoint2operator*= (const IPoint2 &a)
 Member-wise, in-place multiplication of this vector: (x*x, y*y) More...
 
constexpr IPoint2operator/= (const IPoint2 &a)
 Member-wise, in-place division of this vector: More...
 
constexpr IPoint2operator*= (int f)
 
constexpr IPoint2operator/= (int f)
 
constexpr IPoint2operator+= (int f)
 
constexpr IPoint2operator-= (int f)
 
constexpr IPoint2 operator- (const IPoint2 &a) const
 
constexpr IPoint2 operator+ (const IPoint2 &a) const
 
constexpr IPoint2 operator* (const IPoint2 &a) const
 Member-wise multiplication of two vectors: (x*x, y*y) More...
 
constexpr IPoint2 operator/ (const IPoint2 &a) const
 Member-wise division of two vectors: More...
 
constexpr int DotProd (const IPoint2 &a) const
 
constexpr int operator% (const IPoint2 &a) const
 
constexpr bool operator== (const IPoint2 &a) const
 
constexpr bool operator!= (const IPoint2 &a) const
 

Public Attributes

int x = 0
 
int y = 0
 

Static Public Attributes

static const IPoint2 Origin
 
static const IPoint2 XAxis
 
static const IPoint2 YAxis
 

Detailed Description

See also
Class Point2.

Description:
This class describes a 2D point using int x and y coordinates. Methods are provided to add and subtract points, multiply and divide by scalars, normalize and compute the dot product of two IPoint2s. All methods are implemented by the system.
Data Members:
int x,y;

Constructor & Destructor Documentation

◆ IPoint2() [1/5]

IPoint2 ( )
default

◆ IPoint2() [2/5]

constexpr IPoint2 ( const IPoint2 )
constexprdefault

◆ IPoint2() [3/5]

constexpr IPoint2 ( IPoint2 &&  )
constexprdefault

◆ IPoint2() [4/5]

constexpr IPoint2 ( int  X,
int  Y 
)
inlineconstexpr
Remarks
Constructor. Data members are initialized to X and Y.
42 : x(X), y(Y) {}
int y
Definition: ipoint2.h:33
int x
Definition: ipoint2.h:32

◆ IPoint2() [5/5]

constexpr IPoint2 ( int  af[2])
inlineconstexpr
Remarks
Constructor. Data members are initialized as x = af[0] and y = af[1].
44 : x(af[0]), y(af[1]) {}

Member Function Documentation

◆ operator=() [1/2]

IPoint2& operator= ( const IPoint2 )
default

◆ operator=() [2/2]

IPoint2& operator= ( IPoint2 &&  )
default

◆ operator[]() [1/2]

int& operator[] ( int  i)
inline
Remarks
Allows access to x, y using the subscript operator.
Returns
An index of 0 will return x, 1 will return y.
54  {
55  assert((i == 0) || (i == 1));
56  return (i == 0) ? x : y;
57  }
#define assert(expr)
Definition: assert1.h:81

◆ operator[]() [2/2]

const int& operator[] ( int  i) const
inline
59  {
60  assert((i == 0) || (i == 1));
61  return (i == 0) ? x : y;
62  }

◆ operator int *()

constexpr operator int * ( )
inlineconstexpr
Remarks
Returns the address of the IPoint2.x.
67  {
68  return &x;
69  }

◆ operator const int *()

constexpr operator const int * ( ) const
inlineconstexpr
71  {
72  return &x;
73  }

◆ operator-() [1/2]

constexpr IPoint2 operator- ( ) const
inlineconstexpr
Remarks
Unary -. Negates both x and y.
78  {
79  return IPoint2(-x, -y);
80  }
IPoint2()=default

◆ operator+() [1/2]

constexpr IPoint2 operator+ ( ) const
inlineconstexpr
Remarks
Unary +. Returns the Ipoint2 unaltered.
83  {
84  return *this;
85  }

◆ LengthSquared()

constexpr int LengthSquared ( ) const
inlineconstexpr
Remarks
Returns the length squared of the IPoint2
89  {
90  return x * x + y * y;
91  }

◆ Length()

float Length ( ) const
inline
Remarks
Returns the length of the IPoint2
95  {
96  return (float)sqrt((double)LengthSquared());
97  }
constexpr int LengthSquared() const
Definition: ipoint2.h:88

◆ 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.

◆ operator-=() [1/2]

constexpr IPoint2& operator-= ( const IPoint2 a)
inlineconstexpr
Remarks
Subtracts a IPoint2 from this IPoint2.
107  {
108  x -= a.x;
109  y -= a.y;
110  return *this;
111  }

◆ operator+=() [1/2]

constexpr IPoint2& operator+= ( const IPoint2 a)
inlineconstexpr
Remarks
Adds a IPoint2 to this IPoint2.
115  {
116  x += a.x;
117  y += a.y;
118  return *this;
119  }

◆ operator*=() [1/2]

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

Member-wise, in-place multiplication of this vector: (x*x, y*y)

123  {
124  x *= a.x;
125  y *= a.y;
126  return *this;
127  }

◆ operator/=() [1/2]

constexpr IPoint2& operator/= ( const IPoint2 a)
inlineconstexpr

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

131  {
132  x /= a.x;
133  y /= a.y;
134  return *this;
135  }

◆ operator*=() [2/2]

constexpr IPoint2& operator*= ( int  f)
inlineconstexpr
Remarks
Multiplies this IPoint2 by an integer value.
139  {
140  x *= f;
141  y *= f;
142  return *this;
143  }

◆ operator/=() [2/2]

constexpr IPoint2& operator/= ( int  f)
inlineconstexpr
Remarks
Divides this IPoint2 by an integer value.
147  {
148  x /= f;
149  y /= f;
150  return *this;
151  }

◆ operator+=() [2/2]

constexpr IPoint2& operator+= ( int  f)
inlineconstexpr
Remarks
Adds floating point value to this Point2.
155  {
156  x += f;
157  y += f;
158  return *this;
159  }

◆ operator-=() [2/2]

constexpr IPoint2& operator-= ( int  f)
inlineconstexpr
Remarks
Subtracts floating point value from this Point2.
163  {
164  return *this += -f;
165  }

◆ operator-() [2/2]

constexpr IPoint2 operator- ( const IPoint2 a) const
inlineconstexpr
Remarks
Subtracts IPoint2 from this IPoint2.
170  {
171  return IPoint2(x - a.x, y - a.y);
172  }

◆ operator+() [2/2]

constexpr IPoint2 operator+ ( const IPoint2 a) const
inlineconstexpr
Remarks
Adds IPoint2 to this IPoint2.
175  {
176  return IPoint2(x + a.x, y + a.y);
177  }

◆ operator*()

constexpr IPoint2 operator* ( const IPoint2 a) const
inlineconstexpr

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

181  {
182  return IPoint2(x * a.x, y * a.y);
183  }

◆ operator/()

constexpr IPoint2 operator/ ( const IPoint2 a) const
inlineconstexpr

Member-wise division of two vectors:

187  {
188  return IPoint2(x / a.x, y / a.y);
189  }

◆ DotProd()

constexpr int DotProd ( const IPoint2 a) const
inlineconstexpr
Remarks
Returns the dot product of two IPoint2's.
193  {
194  return x * a.x + y * a.y;
195  }

◆ operator%()

constexpr int operator% ( const IPoint2 a) const
inlineconstexpr
197  {
198  return DotProd(a);
199  }
constexpr int DotProd(const IPoint2 &a) const
Definition: ipoint2.h:192

◆ operator==()

constexpr bool operator== ( const IPoint2 a) const
inlineconstexpr
Remarks
Equality operator. Compares two Point2's.
204  {
205  return x == a.x && y == a.y;
206  }

◆ operator!=()

constexpr bool operator!= ( const IPoint2 a) const
inlineconstexpr
208  {
209  return !(*this == a);
210  }

Member Data Documentation

◆ x

int x = 0

◆ y

int y = 0

◆ Origin

const IPoint2 Origin
static

◆ XAxis

const IPoint2 XAxis
static

◆ YAxis

const IPoint2 YAxis
static