ge211  2021.5.1
A student game engine
ge211::geometry Namespace Reference

Detailed Description

Geometric objects and their operations.

Classes

struct  Dims
 Represents the dimensions of an object, or more generally, the displacement between two Posns. More...
 
class  origin_type
 The type of the special value the_origin. More...
 
struct  Posn
 A position in the COORDINATE-valued Cartesian plane, where COORDINATE can be any arithmetic type. More...
 
struct  Rect
 Represents a positioned rectangle. More...
 
class  Transform
 A rendering transformation, which can scale, flip, and rotate. More...
 

Functions

template<typename COORDINATE , typename SCALAR , typename = std::enable_if_t<Is_Arithmetic<SCALAR>>>
Dims< COORDINATE > operator* (SCALAR scalar, Dims< COORDINATE > dims)
 Multiplies a scalar and a Dims. More...
 
Factory functions
template<typename COORDINATE >
Dims< COORDINATE > make_dims (COORDINATE x, COORDINATE y)
 Constructs a Dims given the width and height. More...
 
template<typename COORDINATE >
Posn< COORDINATE > make_posn (COORDINATE x, COORDINATE y)
 Constructs a Posn given the x and y coordinates. More...
 
template<typename COORDINATE >
Rect< COORDINATE > make_rect (COORDINATE x, COORDINATE y, COORDINATE width, COORDINATE height)
 Constructs a Rect given its member variables. More...
 
Stream-insertion operators
template<typename COORDINATE >
std::ostreamoperator<< (std::ostream &out, Dims< COORDINATE > dims)
 Formats a Dims on an output stream.
 
template<typename COORDINATE >
std::ostreamoperator<< (std::ostream &out, Posn< COORDINATE > p)
 Formats a Posn on an output stream.
 
template<typename COORDINATE >
std::ostreamoperator<< (std::ostream &out, Rect< COORDINATE > rect)
 Formats a Rect on an output stream.
 

Variables

constexpr origin_type the_origin
 Gets implicitly converted to Posn<COORDINATE>(0, 0) for any coordinate type COORDINATE. More...
 

Function Documentation

◆ make_dims()

Dims<COORDINATE> ge211::geometry::make_dims ( COORDINATE  x,
COORDINATE  y 
)

Constructs a Dims given the width and height.

Unlike the constructor, this function can infer the coordinate type from its arguments. For example:

auto near = make_dims(5, 7); // Dims<int>
auto far = make_dims(5, 7e9); // Dims<double>

Definition at line 941 of file ge211_geometry.hxx.

◆ make_posn()

Posn<COORDINATE> ge211::geometry::make_posn ( COORDINATE  x,
COORDINATE  y 
)

Constructs a Posn given the x and y coordinates.

Unlike the constructor, this function can infer the coordinate type from its arguments. For example:

auto here = make_posn( 0, 0); // Posn<int>
auto there = make_posn(-5, 7e9); // Posn<double>

Definition at line 957 of file ge211_geometry.hxx.

◆ make_rect()

Rect<COORDINATE> ge211::geometry::make_rect ( COORDINATE  x,
COORDINATE  y,
COORDINATE  width,
COORDINATE  height 
)

Constructs a Rect given its member variables.

It takes them in the same order as the constructor: the x and y coordinates followed by the width and height.

Unlike the constructor, this function can infer the coordinate type from its arguments. For example:

// infers Rect<double>:
auto unit_square = make_rect(0., 0., 1., 1.);
// infers Rect<int>:
auto big_reversi = make_rect(0, 0, 16, 16);

Definition at line 980 of file ge211_geometry.hxx.

◆ operator*()

Dims<COORDINATE> ge211::geometry::operator* ( SCALAR  scalar,
Dims< COORDINATE >  dims 
)

Multiplies a scalar and a Dims.

(This is scalar-vector multiplication.)

Definition at line 255 of file ge211_geometry.hxx.

Variable Documentation

◆ the_origin

constexpr origin_type the_origin
constexpr

Gets implicitly converted to Posn<COORDINATE>(0, 0) for any coordinate type COORDINATE.

Examples:

Definition at line 924 of file ge211_geometry.hxx.

ge211::geometry::Rect::from_top_left
static Rect from_top_left(Posn_type tl, Dims_type dims)
Creates a Rect given the position of its top left vertex and its dimensions.
Definition: ge211_geometry.hxx:605
ge211::geometry::make_dims
Dims< COORDINATE > make_dims(COORDINATE x, COORDINATE y)
Constructs a Dims given the width and height.
Definition: ge211_geometry.hxx:941
ge211::geometry::make_posn
Posn< COORDINATE > make_posn(COORDINATE x, COORDINATE y)
Constructs a Posn given the x and y coordinates.
Definition: ge211_geometry.hxx:957
ge211::geometry::the_origin
constexpr origin_type the_origin
Gets implicitly converted to Posn<COORDINATE>(0, 0) for any coordinate type COORDINATE.
Definition: ge211_geometry.hxx:924
ge211::geometry::make_rect
Rect< COORDINATE > make_rect(COORDINATE x, COORDINATE y, COORDINATE width, COORDINATE height)
Constructs a Rect given its member variables.
Definition: ge211_geometry.hxx:980
ge211::geometry::Posn
A position in the COORDINATE-valued Cartesian plane, where COORDINATE can be any arithmetic type.
Definition: ge211_geometry.hxx:266