Beatmup
Beatmup::CustomPoint< numeric > Class Template Reference

2D point class More...

#include <geometry.h>

Public Member Functions

numeric getX () const
 
numeric getY () const
 
bool operator== (const CustomPoint< numeric > &_) const
 
bool operator!= (const CustomPoint< numeric > &_) const
 
CustomPoint< numeric > operator+ (const CustomPoint< numeric > &_) const
 
CustomPoint< numeric > operator- (const CustomPoint< numeric > &_) const
 
CustomPoint< numeric > operator* (const CustomPoint< numeric > &_) const
 
CustomPoint< numeric > operator/ (const CustomPoint< numeric > &_) const
 
CustomPoint< numeric > operator+ (numeric _) const
 
CustomPoint< numeric > operator- (numeric _) const
 
CustomPoint< numeric > operator* (numeric _) const
 
CustomPoint< numeric > operator/ (numeric _) const
 
void translate (numeric x, numeric y)
 
 CustomPoint ()
 
 CustomPoint (numeric x, numeric y)
 
numeric hypot2 () const
 
bool isInsideAxesSpan (numeric scaleX, numeric scaleY) const
 
 operator CustomPoint< float > () const
 Typecast to float-valued coordinates. More...
 
 operator CustomPoint< int > () const
 Typecast to integer valued coordinates. More...
 

Public Attributes

numeric x
 
numeric y
 

Static Public Attributes

static const CustomPoint ZERO = CustomPoint<T>(0, 0)
 

Detailed Description

template<typename numeric>
class Beatmup::CustomPoint< numeric >

2D point class

Definition at line 38 of file geometry.h.

Constructor & Destructor Documentation

◆ CustomPoint() [1/2]

template<typename numeric >
Beatmup::CustomPoint< numeric >::CustomPoint ( )
inline

Definition at line 90 of file geometry.h.

95 { x = y = 0; }

◆ CustomPoint() [2/2]

template<typename numeric >
Beatmup::CustomPoint< numeric >::CustomPoint ( numeric  x,
numeric  y 
)
inline

Definition at line 90 of file geometry.h.

96 : x(x), y(y) {}

Member Function Documentation

◆ getX()

template<typename numeric >
numeric Beatmup::CustomPoint< numeric >::getX ( ) const
inline

Definition at line 42 of file geometry.h.

42  {
43  return x;
44  }

◆ getY()

template<typename numeric >
numeric Beatmup::CustomPoint< numeric >::getY ( ) const
inline

Definition at line 46 of file geometry.h.

46  {
47  return y;
48  }

◆ operator==()

template<typename numeric >
bool Beatmup::CustomPoint< numeric >::operator== ( const CustomPoint< numeric > &  _) const
inline

Definition at line 50 of file geometry.h.

50  {
51  return x == _.x && y == _.y;
52  }

◆ operator!=()

template<typename numeric >
bool Beatmup::CustomPoint< numeric >::operator!= ( const CustomPoint< numeric > &  _) const
inline

Definition at line 54 of file geometry.h.

54  {
55  return x != _.x || y != _.y;
56  }

◆ operator+() [1/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator+ ( const CustomPoint< numeric > &  _) const
inline

Definition at line 58 of file geometry.h.

58  {
59  return CustomPoint<numeric>(x + _.x, y + _.y);
60  }
2D point class
Definition: geometry.h:38

◆ operator-() [1/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator- ( const CustomPoint< numeric > &  _) const
inline

Definition at line 62 of file geometry.h.

62  {
63  return CustomPoint<numeric>(x - _.x, y - _.y);
64  }

◆ operator*() [1/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator* ( const CustomPoint< numeric > &  _) const
inline

Definition at line 66 of file geometry.h.

66  {
67  return CustomPoint<numeric>(x * _.x, y * _.y);
68  }

◆ operator/() [1/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator/ ( const CustomPoint< numeric > &  _) const
inline

Definition at line 70 of file geometry.h.

70  {
71  return CustomPoint<numeric>(x / _.x, y / _.y);
72  }

◆ operator+() [2/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator+ ( numeric  _) const
inline

Definition at line 74 of file geometry.h.

74  {
75  return CustomPoint<numeric>(x + _, y + _);
76  }

◆ operator-() [2/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator- ( numeric  _) const
inline

Definition at line 78 of file geometry.h.

78  {
79  return CustomPoint<numeric>(x - _, y - _);
80  }

◆ operator*() [2/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator* ( numeric  _) const
inline

Definition at line 82 of file geometry.h.

82  {
83  return CustomPoint<numeric>(x * _, y * _);
84  }

◆ operator/() [2/2]

template<typename numeric >
CustomPoint<numeric> Beatmup::CustomPoint< numeric >::operator/ ( numeric  _) const
inline

Definition at line 86 of file geometry.h.

86  {
87  return CustomPoint<numeric>(x / _, y / _);
88  }

◆ translate()

template<typename numeric >
void Beatmup::CustomPoint< numeric >::translate ( numeric  x,
numeric  y 
)
inline

Definition at line 90 of file geometry.h.

90  {
91  this->x += x;
92  this->y += y;
93  }

◆ hypot2()

template<typename numeric >
numeric Beatmup::CustomPoint< numeric >::hypot2 ( ) const
inline

Definition at line 98 of file geometry.h.

98  {
99  return x*x + y*y;
100  }

◆ isInsideAxesSpan()

template<typename numeric >
bool Beatmup::CustomPoint< numeric >::isInsideAxesSpan ( numeric  scaleX,
numeric  scaleY 
) const
inline

Definition at line 102 of file geometry.h.

102  {
103  return 0 <= x && x <= scaleX && 0 <= y && y <= scaleY;
104  }

◆ operator CustomPoint< float >()

template<typename numeric >
Beatmup::CustomPoint< numeric >::operator CustomPoint< float > ( ) const
inline

Typecast to float-valued coordinates.

Definition at line 109 of file geometry.h.

109  {
110  CustomPoint<float> p((float)x, (float)y);
111  return p;
112  }
Beatmup::IntPoint p((int) x,(int) y)

◆ operator CustomPoint< int >()

template<typename numeric >
Beatmup::CustomPoint< numeric >::operator CustomPoint< int > ( ) const
inline

Typecast to integer valued coordinates.

Definition at line 117 of file geometry.h.

117  {
118  CustomPoint<int> p((int)(x), (int)(y));
119  return p;
120  }

Member Data Documentation

◆ x

template<typename numeric >
numeric Beatmup::CustomPoint< numeric >::x

Definition at line 40 of file geometry.h.

◆ y

template<typename numeric >
numeric Beatmup::CustomPoint< numeric >::y

Definition at line 40 of file geometry.h.

◆ ZERO

template<typename T >
const CustomPoint< T > Beatmup::CustomPoint< T >::ZERO = CustomPoint<T>(0, 0)
static

Definition at line 122 of file geometry.h.


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