ASGE  3.2.0
Simple Game Framework in GL
ASGE::Point2D Struct Reference

#include <Point2D.hpp>

Public Member Functions

 Point2D (float x=0, float y=0)
 
Point2Doperator= (const Point2D &)
 
Point2D midpoint (const Point2D &rhs) const
 
float distance (const Point2D &rhs) const
 
Point2Doperator+= (const Point2D &rhs)
 
Point2Doperator*= (float scalar)
 
Point2D operator* (float scalar) const
 
 Point2D (const Point2D &)=default
 
 Point2D (Point2D &&) noexcept
 
Point2Doperator= (Point2D &&) noexcept
 
bool operator== (const Point2D &rhs) const
 
bool operator!= (const Point2D &rhs) const
 
std::string toString () const
 

Public Attributes

float x = 0
 
float y = 0
 

Detailed Description

A point in 2D space.

Used to represent a position in 2D space. Includes some basic helper functionality for distance and mid-point calculations.

Definition at line 30 of file Point2D.hpp.

Constructor & Destructor Documentation

◆ Point2D()

ASGE::Point2D::Point2D ( float  x = 0,
float  y = 0 
)

Default constructor. The constructor takes will default the position to 0,0 unless the x or x and y parameters are provided. These are then mapped on the x,y values inside the struct.

Parameters
xThe x coordinate.
yThe y coordinate.

Member Function Documentation

◆ distance()

float ASGE::Point2D::distance ( const Point2D rhs) const

Distance. Given two points, calculate the distance between them.

Parameters
Thesecond point to use.
Returns
The distance between the two points.

◆ midpoint()

Point2D ASGE::Point2D::midpoint ( const Point2D rhs) const

Midpoint. Calculates the midpoint between two different points.

Parameters
rhsThe second point to use.
Returns
The midpoint as a Point2D.

◆ operator=()

Point2D& ASGE::Point2D::operator= ( const Point2D )

Assigns the value of another point2D to this one. Assignment constructor, that copies each field from rhs in to the lhs.

Parameters
Point2D.

◆ toString()

std::string ASGE::Point2D::toString ( ) const

Converts to string. Human-friendly version of the Point2D

Returns
The string representation of the Point2D class

Member Data Documentation

◆ x

float ASGE::Point2D::x = 0

the x position.

Definition at line 32 of file Point2D.hpp.

◆ y

float ASGE::Point2D::y = 0

the y position.

Definition at line 33 of file Point2D.hpp.


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