CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::Size Class Reference

2D/3D extent (width, height, optional depth) stored as doubles. More...

#include <MathClasses.h>

Public Member Functions

 Size ()
 Zero size.
 Size (double width, double height, double depth=0)
 From explicit dimensions.
virtual ~Size ()
bool equals (const Size &size) const
 Exact component equality.
bool operator== (const Size &p) const
 Same as equals().
Size operator* (const Vector2D &v) const
 Scale w by v.x and h by v.y.
double getHeight () const
double getWidth () const
double getDepth () const
bool setHeight (double height)
 Set height.
bool setWidth (double width)
 Set width.
bool setDepth (double depth)
 Set depth.
bool isNonZero () const
double getArea () const
double getDiagonalLenth () const
std::string print ()
 Human-readable representation for debugging.

Public Attributes

double w
 Width.
double h
 Height.
double d
 Depth (0 for 2D use).

Detailed Description

2D/3D extent (width, height, optional depth) stored as doubles.

Definition at line 334 of file MathClasses.h.

Constructor & Destructor Documentation

◆ Size() [1/2]

cmlabs::Size::Size ( )

Zero size.

Definition at line 15 of file MathClasses.cpp.

References d, h, and w.

Referenced by equals(), operator*(), and operator==().

◆ Size() [2/2]

cmlabs::Size::Size ( double width,
double height,
double depth = 0 )

From explicit dimensions.

Definition at line 16 of file MathClasses.cpp.

References d, h, and w.

◆ ~Size()

cmlabs::Size::~Size ( )
virtual

Definition at line 17 of file MathClasses.cpp.

Member Function Documentation

◆ equals()

bool cmlabs::Size::equals ( const Size & size) const

Exact component equality.

Returns
true when equal.

Definition at line 19 of file MathClasses.cpp.

References d, h, Size(), and w.

Referenced by _wrap_Size_equals(), and operator==().

◆ getArea()

double cmlabs::Size::getArea ( ) const
Returns
w*h.

Definition at line 50 of file MathClasses.cpp.

References getHeight(), and getWidth().

Referenced by _wrap_Size_getArea(), cmlabs::MathClasses_UnitTest(), and cmlabs::Box::percentOverlap().

◆ getDepth()

double cmlabs::Size::getDepth ( ) const
Returns
Depth.

Definition at line 40 of file MathClasses.cpp.

References d.

Referenced by _wrap_Size_getDepth().

◆ getDiagonalLenth()

double cmlabs::Size::getDiagonalLenth ( ) const
Returns
Diagonal length sqrt(w²+h²).
Note
Name typo kept for API stability.

Definition at line 54 of file MathClasses.cpp.

References getHeight(), and getWidth().

Referenced by _wrap_Size_getDiagonalLenth(), and cmlabs::MathClasses_UnitTest().

◆ getHeight()

double cmlabs::Size::getHeight ( ) const
Returns
Height.

Definition at line 38 of file MathClasses.cpp.

References h.

Referenced by _wrap_Size_getHeight(), getArea(), getDiagonalLenth(), and cmlabs::MathClasses_UnitTest().

◆ getWidth()

double cmlabs::Size::getWidth ( ) const
Returns
Width.

Definition at line 39 of file MathClasses.cpp.

References w.

Referenced by _wrap_Size_getWidth(), getArea(), getDiagonalLenth(), and cmlabs::MathClasses_UnitTest().

◆ isNonZero()

bool cmlabs::Size::isNonZero ( ) const
Returns
true when any dimension is non-zero.

Definition at line 46 of file MathClasses.cpp.

References d, h, and w.

Referenced by _wrap_Size_isNonZero(), cmlabs::MathClasses_UnitTest(), and cmlabs::Box::percentOverlap().

◆ operator*()

Size cmlabs::Size::operator* ( const Vector2D & v) const

Scale w by v.x and h by v.y.

Returns
Scaled size.

Definition at line 30 of file MathClasses.cpp.

References h, Size(), w, cmlabs::Vector2D::x, and cmlabs::Vector2D::y.

◆ operator==()

bool cmlabs::Size::operator== ( const Size & p) const

Same as equals().

Definition at line 26 of file MathClasses.cpp.

References equals(), and Size().

◆ print()

std::string cmlabs::Size::print ( )

Human-readable representation for debugging.

Definition at line 58 of file MathClasses.cpp.

References d, h, cmlabs::utils::StringFormat(), and w.

◆ setDepth()

bool cmlabs::Size::setDepth ( double depth)

Set depth.

Returns
true.

Definition at line 44 of file MathClasses.cpp.

References d.

◆ setHeight()

bool cmlabs::Size::setHeight ( double height)

Set height.

Returns
true.

Definition at line 42 of file MathClasses.cpp.

References h.

◆ setWidth()

bool cmlabs::Size::setWidth ( double width)

Set width.

Returns
true.

Definition at line 43 of file MathClasses.cpp.

References w.

Member Data Documentation

◆ d

double cmlabs::Size::d

Depth (0 for 2D use).

Definition at line 343 of file MathClasses.h.

Referenced by equals(), getDepth(), isNonZero(), print(), setDepth(), Size(), and Size().

◆ h

◆ w


The documentation for this class was generated from the following files: