Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
DsPoint Class Reference

DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers. More...

#include <ds_geometry.h>

Public Member Functions

 DsPoint ()
 Creates a DsPoint object initialized to (0, 0).
 
 DsPoint (int32_t x, int32_t y)
 Creates a DsPoint object initialized to (x, y).
 
DsPointoperator= (const DsFPoint &rhs)
 Assignment operator from a DsFPoint object.
 
void swap (void)
 Swaps the X and Y coordinates of the current DsPoint object.
 
bool operator== (const DsPoint &rhs)
 Comparison operator.
 
DsPoint operator- () const
 Unary minus operator. Reverses the signs of both the X and Y coordinates of the current DsPoint object.
 
DsPointoperator+= (const DsPoint &rhs)
 Addition operator - adds a DsPoint object to the current DsPoint object.
 
DsPointoperator+= (int32_t rhs)
 Addition operator - adds a number to both the X and Y coordinates of the current DsPoint object.
 
DsPointoperator-= (const DsPoint &rhs)
 Subtraction operator - subtract a DsPoint object from the current DsPoint object.
 
DsPointoperator-= (int32_t rhs)
 Subtraction operator - subtract a number from the current DsPoint object.
 
DsPoint saturateMin (const DsPoint &min)
 Saturates the current DsPoint object coordinates to the minimum specified.
 
DsPoint saturateMax (const DsPoint &max)
 Saturates the current DsPoint object coordinates to the maximum specified.
 
DsPoint saturate (const DsPoint &min, const DsPoint &max)
 Saturates the current DsPoint object coordinates to the minimum and maximum specified.
 
float distance (const DsPoint &p) const
 Calculates the Euclidian distance between the current DsPoint object and a second DsPoint object.
 
float distanceX (const DsPoint &p) const
 Calculates the X component of the Euclidian distance between the current DsPoint object and a second DsPoint object.
 
float distanceY (const DsPoint &p) const
 Calculates the Y component of the Euclidian distance between the current DsPoint object and a second DsPoint object.
 

Public Attributes

int32_t x
 X component.
 
int32_t y
 Y component.
 

Friends

DsPoint operator+ (const DsPoint &lhs, const DsPoint &rhs)
 Addition operator - adds two DsPoint objects.
 
DsPoint operator+ (const DsPoint &lhs, int32_t rhs)
 Addition operator - adds a number to both the X and Y coordinates of a DsPoint object.
 
DsPoint operator- (const DsPoint &lhs, const DsPoint &rhs)
 Subtraction operator - subtract two DsPoint objects.
 
DsPoint operator- (const DsPoint &lhs, int32_t rhs)
 Subtraction operator - subtract a number from a DsPoint object.
 
DsPoint operator* (const DsPoint &lhs, int32_t multiplier)
 Multiplication operator - multiplies both X and Y coordinates of a DsPoint object with the same multiplier.
 
DsPoint operator/ (const DsPoint &lhs, int32_t divisor)
 Integer division operator - divides both X and Y coordinates of a DsPoint object by the same divisor.
 
DsPoint operator/ (const DsPoint &lhs, float divisor)
 Integer division operator - divides both X and Y coordinates of a DsPoint object by the same divisor.
 
float distance (const DsPoint &p1, const DsPoint &p2)
 Calculates the Euclidian distance between two DsPoint objects.
 

Detailed Description

DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.

Constructor & Destructor Documentation

◆ DsPoint()

DsPoint::DsPoint ( int32_t  x,
int32_t  y 
)
inline

Creates a DsPoint object initialized to (x, y).

Parameters
xX coordinate
yY coordinate

Member Function Documentation

◆ distance()

float DsPoint::distance ( const DsPoint p) const
inline

Calculates the Euclidian distance between the current DsPoint object and a second DsPoint object.

Parameters
pSecond DsPoint object
Returns
Euclidian distance

◆ distanceX()

float DsPoint::distanceX ( const DsPoint p) const
inline

Calculates the X component of the Euclidian distance between the current DsPoint object and a second DsPoint object.

Parameters
pSecond DsPoint object
Returns
X component of the Euclidian distance

◆ distanceY()

float DsPoint::distanceY ( const DsPoint p) const
inline

Calculates the Y component of the Euclidian distance between the current DsPoint object and a second DsPoint object.

Parameters
pSecond DsPoint object
Returns
Y component of the Euclidian distance

◆ operator+=() [1/2]

DsPoint & DsPoint::operator+= ( const DsPoint rhs)
inline

Addition operator - adds a DsPoint object to the current DsPoint object.

Parameters
rhsRight hand side DsPoint object
Returns
Object reference

◆ operator+=() [2/2]

DsPoint & DsPoint::operator+= ( int32_t  rhs)
inline

Addition operator - adds a number to both the X and Y coordinates of the current DsPoint object.

Parameters
rhsRight hand side number
Returns
Object reference

◆ operator-()

DsPoint DsPoint::operator- ( ) const
inline

Unary minus operator. Reverses the signs of both the X and Y coordinates of the current DsPoint object.

Returns
DsPoint object with both the X and Y components of the current object having the signs reversed

◆ operator-=() [1/2]

DsPoint & DsPoint::operator-= ( const DsPoint rhs)
inline

Subtraction operator - subtract a DsPoint object from the current DsPoint object.

Parameters
rhsRight hand side DsPoint object
Returns
Object reference

◆ operator-=() [2/2]

DsPoint & DsPoint::operator-= ( int32_t  rhs)
inline

Subtraction operator - subtract a number from the current DsPoint object.

Parameters
rhsRight hand side number
Returns
Object reference

◆ operator=()

DsPoint & DsPoint::operator= ( const DsFPoint rhs)

Assignment operator from a DsFPoint object.

Parameters
rhsSource point

◆ operator==()

bool DsPoint::operator== ( const DsPoint rhs)
inline

Comparison operator.

Parameters
rhsRight hand side point of the comparison operator

◆ saturate()

DsPoint DsPoint::saturate ( const DsPoint min,
const DsPoint max 
)
inline

Saturates the current DsPoint object coordinates to the minimum and maximum specified.

Parameters
minMinimum value
maxMaximum value
Returns
Saturated DsPoint object

◆ saturateMax()

DsPoint DsPoint::saturateMax ( const DsPoint max)
inline

Saturates the current DsPoint object coordinates to the maximum specified.

Parameters
minMaximum value
Returns
Saturated DsPoint object

◆ saturateMin()

DsPoint DsPoint::saturateMin ( const DsPoint min)
inline

Saturates the current DsPoint object coordinates to the minimum specified.

Parameters
minMinimum value
Returns
Saturated DsPoint object

Friends And Related Symbol Documentation

◆ distance

float distance ( const DsPoint p1,
const DsPoint p2 
)
friend

Calculates the Euclidian distance between two DsPoint objects.

Parameters
p1First DsPoint object
p2Second DsPoint object
Returns
Euclidian distance

◆ operator*

DsPoint operator* ( const DsPoint lhs,
int32_t  multiplier 
)
friend

Multiplication operator - multiplies both X and Y coordinates of a DsPoint object with the same multiplier.

Parameters
lhsLeft hand side DsPoint object
multiplierRight hand side multiplier
Returns
lfs DsPoint object multiplied by the multiplier

◆ operator+ [1/2]

DsPoint operator+ ( const DsPoint lhs,
const DsPoint rhs 
)
friend

Addition operator - adds two DsPoint objects.

Parameters
lhsLeft hand side DsPoint objects
rhsRight hand side DsPoint objects
Returns
The sum of lhs and rhs DsPoint objects

◆ operator+ [2/2]

DsPoint operator+ ( const DsPoint lhs,
int32_t  rhs 
)
friend

Addition operator - adds a number to both the X and Y coordinates of a DsPoint object.

Parameters
lhsLeft hand side DsPoint object
rhsRight hand side number
Returns
The sum of lhs object and the rhs number (x + rhs, y + rhs)

◆ operator- [1/2]

DsPoint operator- ( const DsPoint lhs,
const DsPoint rhs 
)
friend

Subtraction operator - subtract two DsPoint objects.

Parameters
lhsLeft hand side DsPoint object
rhsRight hand side DsPoint object
Returns
The difference between lhs and rhs DsPoint objects

◆ operator- [2/2]

DsPoint operator- ( const DsPoint lhs,
int32_t  rhs 
)
friend

Subtraction operator - subtract a number from a DsPoint object.

Parameters
lhsLeft hand side DsPoint object
rhsRight hand side number
Returns
The difference between lhs object and the rhs number (x - rhs, y - rhs)

◆ operator/ [1/2]

DsPoint operator/ ( const DsPoint lhs,
float  divisor 
)
friend

Integer division operator - divides both X and Y coordinates of a DsPoint object by the same divisor.

Parameters
lhsLeft hand side DsPoint object
divisorRight hand side divisor
Returns
lfs DsPoint object divided by the divisor

◆ operator/ [2/2]

DsPoint operator/ ( const DsPoint lhs,
int32_t  divisor 
)
friend

Integer division operator - divides both X and Y coordinates of a DsPoint object by the same divisor.

Parameters
lhsLeft hand side DsPoint object
divisorRight hand side divisor
Returns
lfs DsPoint object divided by the divisor

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