3ds Max C++ API Reference
DBox2 Class Reference

#include <dbox2.h>

Public Member Functions

 DBox2 ()=default
 Constructor. More...
 
 DBox2 (const DBox2 &)=default
 
 DBox2 (DBox2 &&)=default
 
DBox2operator= (const DBox2 &)=default
 
DBox2operator= (DBox2 &&)=default
 
 DBox2 (const DPoint2 &p, const DPoint2 &q)
 Constructor. More...
 
void Init ()
 Initializes this box such that pmin is a very large value while pmax is a small value. More...
 
DPoint2 Min () const
 Returns the minimum corner value. More...
 
DPoint2 Max () const
 Returns the maximum corner value. More...
 
DPoint2 Center () const
 Returns the center of this DBox2 as a DPoint2. More...
 
DPoint2 Width () const
 Returns the width of the box as a DPoint2. More...
 
DBox2operator+= (const DPoint2 &p)
 Expands this DBox2 to include the DPoint2 p. More...
 
DBox2operator+= (const DBox2 &b)
 Expands this DBox2 to include the specified DBox2. More...
 
void Scale (double s)
 Scales this box about its center by the specified scale. More...
 
void Translate (const DPoint2 &p)
 Translates this box by the distance specified. More...
 
void EnlargeBy (double s)
 Enlarges this box. More...
 
int IsEmpty () const
 Determines if the box is empty. More...
 
int Contains (const DPoint2 &p) const
 Determines if the specified point p is contained in this box. More...
 
int Contains (const DBox2 &b) const
 Determines if the specified DBox2 is contained totally within this box. More...
 
int Overlaps (const DBox2 &b) const
 Determines if the specified DBox2 overlaps this box. More...
 

Public Attributes

DPoint2 pmin { DBL_MAX, DBL_MAX }
 The minimum 2D point in this box. More...
 
DPoint2 pmax { DBL_MIN, DBL_MIN }
 The maximum 2D point in this box. More...
 

Detailed Description

See also
Class DPoint2.

This class represents a 2D box described by two double-precision 2D corner coordinates. DBox2 provides methods that return individual coordinates of the box, scale and translate it, retrieve its center, modify its size, expand it to include points or other boxes, and determine if points are inside the box. All methods are implemented by the system.

Constructor & Destructor Documentation

◆ DBox2() [1/4]

DBox2 ( )
default

Constructor.

The corners of the box are initialized such that the box is 'empty'. See

See also
IsEmpty().

◆ DBox2() [2/4]

DBox2 ( const DBox2 )
default

◆ DBox2() [3/4]

DBox2 ( DBox2 &&  )
default

◆ DBox2() [4/4]

DBox2 ( const DPoint2 p,
const DPoint2 q 
)
inline

Constructor.

The corners of the box are initialized to the points passed.

Parameters
pThe first corner of the box
qThe second corner of the box
47  {
48  pmin = p;
49  pmax = q;
50  }
DPoint2 pmin
The minimum 2D point in this box.
Definition: dbox2.h:28
DPoint2 pmax
The maximum 2D point in this box.
Definition: dbox2.h:31

Member Function Documentation

◆ operator=() [1/2]

DBox2& operator= ( const DBox2 )
default

◆ operator=() [2/2]

DBox2& operator= ( DBox2 &&  )
default

◆ Init()

void Init ( )

Initializes this box such that pmin is a very large value while pmax is a small value.

Thus the box is 'empty'. See

See also
IsEmpty().

◆ Min()

DPoint2 Min ( ) const
inline

Returns the minimum corner value.

Returns
the value of corner pmin
62  {
63  return pmin;
64  }

◆ Max()

DPoint2 Max ( ) const
inline

Returns the maximum corner value.

Returns
the value of corner pmax.
69  {
70  return pmax;
71  }

◆ Center()

DPoint2 Center ( ) const
inline

Returns the center of this DBox2 as a DPoint2.

Returns
the center of the box
76  {
77  return (pmin + pmax) / 2.0;
78  }

◆ Width()

DPoint2 Width ( ) const
inline

Returns the width of the box as a DPoint2.

This is pmax-pmin.

Returns
the width of the box
84  {
85  return (pmax - pmin);
86  }

◆ operator+=() [1/2]

DBox2& operator+= ( const DPoint2 p)

Expands this DBox2 to include the DPoint2 p.

Parameters
pthe DPoint2 to include in the new size
Returns
the resulting box

◆ operator+=() [2/2]

DBox2& operator+= ( const DBox2 b)

Expands this DBox2 to include the specified DBox2.

Parameters
bthe box to include in the new size
Returns
the resulting box

◆ Scale()

void Scale ( double  s)

Scales this box about its center by the specified scale.

Parameters
sSpecifies the scale factor for this DBox2.

◆ Translate()

void Translate ( const DPoint2 p)

Translates this box by the distance specified.

The point is added to each corner.

Parameters
pSpecifies the distance to translate the box.

◆ EnlargeBy()

void EnlargeBy ( double  s)

Enlarges this box.

A DPoint2 is created from s as DPoint2(s,s) and added to pmax and subtracted from pmin. If the box is 'empty', the box is centered at (0,0) and then enlarged.

Parameters
sthe amount to enlarge the box on all sides

◆ IsEmpty()

int IsEmpty ( ) const

Determines if the box is empty.

This indicates the box has not had specific values set by the developer.

Returns
Nonzero if the box is empty; otherwise 0.

◆ Contains() [1/2]

int Contains ( const DPoint2 p) const

Determines if the specified point p is contained in this box.

Parameters
pSpecifies the point to check.
Returns
Nonzero if the specified point is contained in this box, otherwise 0.

◆ Contains() [2/2]

int Contains ( const DBox2 b) const

Determines if the specified DBox2 is contained totally within this box.

Parameters
bSpecifies the box to check.
Returns
Nonzero if the specified box is entirely contained within this box; otherwise 0.

◆ Overlaps()

int Overlaps ( const DBox2 b) const

Determines if the specified DBox2 overlaps this box.

Parameters
bSpecifies the box to check.
Returns
Nonzero if the specified box overlaps this box; otherwise 0.

Member Data Documentation

◆ pmin

DPoint2 pmin { DBL_MAX, DBL_MAX }

The minimum 2D point in this box.

◆ pmax

DPoint2 pmax { DBL_MIN, DBL_MIN }

The maximum 2D point in this box.