Rose
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
rose::Position< T > Class Template Reference

A position in integer (x, y) co-ordinates. More...

#include <Types.h>

Inheritance diagram for rose::Position< T >:
Inheritance graph
[legend]
Collaboration diagram for rose::Position< T >:
Collaboration graph
[legend]

Public Member Functions

template<typename O >
constexpr Position (O X, O Y) noexcept
 
constexpr Position (const Position &p)=default
 
constexpr Position (Position &&p) noexcept=default
 
constexpr Positionoperator= (const Position &p)=default
 
constexpr Positionoperator= (Position &&p)=default
 
constexpr Position (T p) noexcept
 
template<typename O >
constexpr Position operator+ (const Position< O > &p) const noexcept
 Add two positions together.
 
template<typename O >
constexpr Position operator- (const Position< O > &p) const noexcept
 Subtract position other from this.
 
template<typename O >
Position< O > as () const
 Return this position after converting to type O. More...
 
bool operator!= (const Position &other) const noexcept
 Inequality operator.
 
bool operator== (const Position &other) const noexcept
 Equality operator.
 
bool operator<= (const Position &other) const noexcept
 Less than or Equal to operator.
 
T & primary (Orientation o) noexcept
 Access the primary component for a given Orientation.
 
T & secondary (Orientation o) noexcept
 Access the secondary component for the given Orientation.
 
constexpr T primary (Orientation o) const noexcept
 Return the primary component for a given Orientation.
 
constexpr T secondary (Orientation o) const noexcept
 Return the secondary component for the given Orientation.
 
constexpr T rSqr (const Position &other) const noexcept
 Compute the distance squared from this position to another. More...
 
void swap () noexcept
 Swap the x and y components.
 
constexpr Position< T > mirrorX () const noexcept
 Mirror Position on X axis.
 
constexpr Position< T > mirrorY () const noexcept
 Mirror Position on Y axis.
 
constexpr Position (std::array< int, 2 > value) noexcept
 Constructor initialize to the value of an array.
 
constexpr Position (int value=0) noexcept
 Default constructor initializes x and y to 0 or to a specified value.
 
constexpr Position (int x, int y) noexcept
 Constructor initialize to descrete x and y values.
 
constexpr Position (const Position &)=default
 Copy constructor.
 
constexpr Position (Position &&)=default
 Move constructor.
 
constexpr Positionoperator= (const Position &)=default
 Copy assignment.
 
constexpr Positionoperator= (Position &&)=default
 Move assignment.
 
constexpr int & x ()
 Reference access to x.
 
constexpr int x () const noexcept
 Value access to x.
 
constexpr int & y ()
 Reference access to y.
 
constexpr int y () const noexcept
 Value access to y.
 
int & primary (Orientation orientation)
 Reference for primary axis value. More...
 
constexpr int primary (Orientation orientation) const noexcept
 Value for primary axis value. More...
 
int & secondary (Orientation orientation)
 Reference for secondary axis value. More...
 
constexpr int secondary (Orientation orientation) const noexcept
 Value for secondary axis value. More...
 
constexpr Position operator+ (const Position &position) const noexcept
 Addition operator.
 
constexpr Position operator- (const Position &position) const noexcept
 Subtraction operator.
 
constexpr int abs () const noexcept
 Compute the square of the scalar distance of a position from the origin. More...
 

Public Attributes

x {0}
 
y {0}
 

Static Public Attributes

static const Position Zero = Position{}
 A zero position.
 

Detailed Description

template<typename T>
class rose::Position< T >

A position in integer (x, y) co-ordinates.

The position, or relative position of an object on the screen.

For screen objects (0, 0) is the top left corner, x increases to the right, y increases toward the bottom.

Member Function Documentation

◆ abs()

template<typename T>
constexpr int rose::Position< T >::abs ( ) const
inlinenoexcept

Compute the square of the scalar distance of a position from the origin.

This can be used on the difference of two positions to get the square of the scalar distance between the two positions.

Returns
the distance squared

◆ as()

template<typename T>
template<typename O >
Position<O> rose::Position< T >::as ( ) const
inline

Return this position after converting to type O.

Template Parameters
OThe type of the returned values.
Returns
The converted position.

◆ primary() [1/2]

template<typename T>
int& rose::Position< T >::primary ( Orientation  orientation)
inline

Reference for primary axis value.

The primary access differs depending on the orientation

◆ primary() [2/2]

template<typename T>
constexpr int rose::Position< T >::primary ( Orientation  orientation) const
inlinenoexcept

Value for primary axis value.

The primary access differs depending on the orientation

◆ rSqr()

template<typename T>
constexpr T rose::Position< T >::rSqr ( const Position< T > &  other) const
inlinenoexcept

Compute the distance squared from this position to another.

Parameters
otherThe other position.
Returns
The distance between the two positions squared.

◆ secondary() [1/2]

template<typename T>
int& rose::Position< T >::secondary ( Orientation  orientation)
inline

Reference for secondary axis value.

The secondary access differs depending on the orientation

◆ secondary() [2/2]

template<typename T>
constexpr int rose::Position< T >::secondary ( Orientation  orientation) const
inlinenoexcept

Value for secondary axis value.

The secondary access differs depending on the orientation


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