levelz-cpp 0.2.0
Loading...
Searching...
No Matches
LevelZ::Coordinate2D Struct Reference

#include <coordinate.hpp>

Inheritance diagram for LevelZ::Coordinate2D:
LevelZ::Coordinate

Public Member Functions

 Coordinate2D ()
 
 Coordinate2D (int x, int y)
 
 Coordinate2D (double x, double y)
 
 Coordinate2D (std::vector< int > xy)
 
 Coordinate2D (std::array< int, 2 > xy)
 
 Coordinate2D (std::vector< double > xy)
 
 Coordinate2D (std::array< double, 2 > xy)
 
double getMagnitude () const
 
bool operator== (const Coordinate2D &other) const
 
bool operator!= (const Coordinate2D &other) const
 
Coordinate2D operator+ (const Coordinate2D &other) const
 
Coordinate2D operator- (const Coordinate2D &other) const
 
Coordinate2D operator* (int scalar) const
 
Coordinate2D operator/ (int scalar) const
 
std::string to_string () const
 
std::ostream & operator<< (std::ostream &strm)
 
- Public Member Functions inherited from LevelZ::Coordinate

Static Public Member Functions

static Coordinate2D from_string (const std::string &str)
 

Public Attributes

double x
 
double y
 

Detailed Description

Represents a 2D coordinate.

Constructor & Destructor Documentation

◆ Coordinate2D() [1/7]

LevelZ::Coordinate2D::Coordinate2D ( )
inline

Initializes a new instance of the Coordinate2D class at [0, 0].

◆ Coordinate2D() [2/7]

LevelZ::Coordinate2D::Coordinate2D ( int x,
int y )
inline

Initializes a new instance of the Coordinate2D class at the specified coordinates.

Parameters
xThe X coordinate.
yThe Y coordinate.

◆ Coordinate2D() [3/7]

LevelZ::Coordinate2D::Coordinate2D ( double x,
double y )
inline

Initializes a new instance of the Coordinate2D class at the specified coordinates.

Parameters
xThe X coordinate.
yThe Y coordinate.

◆ Coordinate2D() [4/7]

LevelZ::Coordinate2D::Coordinate2D ( std::vector< int > xy)
inline

Initializes a new instance of the Coordinate2D class at the specified coordinates.

Parameters
xyThe X and Y coordinates in a vector.

◆ Coordinate2D() [5/7]

LevelZ::Coordinate2D::Coordinate2D ( std::array< int, 2 > xy)
inline

Initializes a new instance of the Coordinate2D class at the specified coordinates.

Parameters
xyThe X and Y coordinates in an array.

◆ Coordinate2D() [6/7]

LevelZ::Coordinate2D::Coordinate2D ( std::vector< double > xy)
inline

Initializes a new instance of the Coordinate2D class at the specified coordinates.

Parameters
xyThe X and Y coordinates in a vector.

◆ Coordinate2D() [7/7]

LevelZ::Coordinate2D::Coordinate2D ( std::array< double, 2 > xy)
inline

Initializes a new instance of the Coordinate2D class at the specified coordinates.

Parameters
xyThe X and Y coordinates in an array.

Member Function Documentation

◆ from_string()

static Coordinate2D LevelZ::Coordinate2D::from_string ( const std::string & str)
inlinestatic

Converts a string to a 2D coordinate.

Parameters
strThe string to convert.
Returns
Coordinate2D The 2D coordinate.

◆ getMagnitude()

double LevelZ::Coordinate2D::getMagnitude ( ) const
inlinevirtual

Gets the magnitude of the coordinate.

Returns
The magnitude of the coordinate.

Implements LevelZ::Coordinate.

◆ operator!=()

bool LevelZ::Coordinate2D::operator!= ( const Coordinate2D & other) const
inline

Compares two coordinates for inequality.

Parameters
otherThe other coordinate to compare to.
Returns
True if the coordinates are not equal, false otherwise.

◆ operator*()

Coordinate2D LevelZ::Coordinate2D::operator* ( int scalar) const
inline

Multiplies the coordinate by a scalar.

Parameters
scalarThe scalar to multiply by.
Returns
The product of the coordinate and the scalar.

◆ operator+()

Coordinate2D LevelZ::Coordinate2D::operator+ ( const Coordinate2D & other) const
inline

Adds two coordinates together.

Parameters
otherThe other coordinate to add.
Returns
The sum of the two coordinates.

◆ operator-()

Coordinate2D LevelZ::Coordinate2D::operator- ( const Coordinate2D & other) const
inline

Subtracts one coordinate from another.

Parameters
otherThe other coordinate to subtract.
Returns
The difference of the two coordinates.

◆ operator/()

Coordinate2D LevelZ::Coordinate2D::operator/ ( int scalar) const
inline

Divides the coordinate by a scalar.

Parameters
scalarThe scalar to divide by.
Returns
The quotient of the coordinate and the scalar.

◆ operator<<()

std::ostream & LevelZ::Coordinate2D::operator<< ( std::ostream & strm)
inline

Overloads the << operator to allow for easy printing of a Coordinate2D.

Parameters
strmThe output stream to write to.
Returns
The output stream.

◆ operator==()

bool LevelZ::Coordinate2D::operator== ( const Coordinate2D & other) const
inline

Compares two coordinates for equality.

Parameters
otherThe other coordinate to compare to.
Returns
True if the coordinates are equal, false otherwise.

◆ to_string()

std::string LevelZ::Coordinate2D::to_string ( ) const
inlinevirtual

Converts this 2D coordinate to a string.

Returns
The string representation of the coordinate.

Implements LevelZ::Coordinate.

Member Data Documentation

◆ x

double LevelZ::Coordinate2D::x

The X coordinate.

◆ y

double LevelZ::Coordinate2D::y

The Y coordinate.


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