ge211
Basic_position< T > Struct Template Reference

Detailed Description

template<class T>
struct ge211::geometry::Basic_position< T >

A position in the T-valued Cartesian plane.

In graphics, the origin is traditionally in the upper left, so the x coordinate increases to the right and the y coordinate increases downward. Note that much of the library uses geometry::Position, which is a type alias for Basic_position<int>.

Definition at line 74 of file ge211_forward.h.

Public Types

using Coordinate = T
 The coordinate type for the position. More...
 
using Dimensions = Basic_dimensions< Coordinate >
 A dimensions type having the same coordinate type as this position type. More...
 

Public Member Functions

Constructors
 Basic_position (Coordinate x, Coordinate y) noexcept(is_nothrow_convertible< Coordinate >())
 Constructs a position from the given x and y coordinates.
 
 Basic_position (Dimensions dims) noexcept(is_nothrow_convertible< Coordinate >())
 Constructs a position from a Basic_dimensions, which gives the displacement of the position from the origin. More...
 
template<class U >
Basic_position< U > into () const noexcept(is_nothrow_convertible< Coordinate, U >())
 Converts a Basic_position to another coordinate type. More...
 
Shifting member functions
Basic_position up_by (Coordinate dy) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is above this position by the given amount. More...
 
Basic_position down_by (Coordinate dy) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is below this position by the given amount. More...
 
Basic_position left_by (Coordinate dx) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is to the left of this position by the given amount. More...
 
Basic_position right_by (Coordinate dx) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is to the right of this position by the given amount. More...
 
Basic_position up_left_by (Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is above and left of this position by the given dimensions. More...
 
Basic_position up_right_by (Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is above and right of this position by the given dimensions. More...
 
Basic_position down_left_by (Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is below and left of this position by the given dimensions. More...
 
Basic_position down_right_by (Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
 Constructs the position that is below and right of this position by the given dimensions. More...
 

Public Attributes

Coordinate x
 The x coordinate.
 
Coordinate y
 The y coordiante.
 

Member Typedef Documentation

◆ Coordinate

using Coordinate = T

The coordinate type for the position.

This is an alias of type parameter T.

Definition at line 217 of file ge211_geometry.h.

◆ Dimensions

A dimensions type having the same coordinate type as this position type.

Definition at line 220 of file ge211_geometry.h.

Constructor & Destructor Documentation

◆ Basic_position()

Basic_position ( Dimensions  dims)
inlineexplicitnoexcept

Constructs a position from a Basic_dimensions, which gives the displacement of the position from the origin.

Definition at line 236 of file ge211_geometry.h.

Member Function Documentation

◆ down_by()

Basic_position down_by ( Coordinate  dy) const
inlinenoexcept

Constructs the position that is below this position by the given amount.

Definition at line 270 of file ge211_geometry.h.

◆ down_left_by()

Basic_position down_left_by ( Dimensions  dims) const
inlinenoexcept

Constructs the position that is below and left of this position by the given dimensions.

Definition at line 310 of file ge211_geometry.h.

◆ down_right_by()

Basic_position down_right_by ( Dimensions  dims) const
inlinenoexcept

Constructs the position that is below and right of this position by the given dimensions.

Definition at line 318 of file ge211_geometry.h.

◆ into()

Basic_position<U> into ( ) const
inlinenoexcept

Converts a Basic_position to another coordinate type.

For example:

Basic_position<int> p1{3, 4};
Basic_position<double> p2 = d1.into<double>();

Definition at line 249 of file ge211_geometry.h.

◆ left_by()

Basic_position left_by ( Coordinate  dx) const
inlinenoexcept

Constructs the position that is to the left of this position by the given amount.

Definition at line 278 of file ge211_geometry.h.

◆ right_by()

Basic_position right_by ( Coordinate  dx) const
inlinenoexcept

Constructs the position that is to the right of this position by the given amount.

Definition at line 286 of file ge211_geometry.h.

◆ up_by()

Basic_position up_by ( Coordinate  dy) const
inlinenoexcept

Constructs the position that is above this position by the given amount.

Definition at line 262 of file ge211_geometry.h.

◆ up_left_by()

Basic_position up_left_by ( Dimensions  dims) const
inlinenoexcept

Constructs the position that is above and left of this position by the given dimensions.

Definition at line 294 of file ge211_geometry.h.

◆ up_right_by()

Basic_position up_right_by ( Dimensions  dims) const
inlinenoexcept

Constructs the position that is above and right of this position by the given dimensions.

Definition at line 302 of file ge211_geometry.h.


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