mcpp
C++ Minecraft Library
Loading...
Searching...
No Matches
mcpp::Coordinate Struct Reference

#include <coordinate.h>

Public Member Functions

constexpr Coordinate (int32_t x, int32_t y, int32_t z)
 Constructs a Coordinate object with integer values.
 
constexpr Coordinate ()
 Constructs a Coordinate object with zero values.
 
constexpr Coordinate (double x, double y, double z)
 Constructs a Coordinate object with double values.
 
Coordinate operator+ (const Coordinate &obj) const
 Adds two Coordinate objects.
 
bool operator== (const Coordinate &obj) const
 Checks if two Coordinate objects are equal.
 
bool operator!= (const Coordinate &obj) const
 Checks if two Coordinate objects are not equal.
 
Coordinate operator- (const Coordinate &obj) const
 Subtracts one Coordinate object from another.
 

Public Attributes

int32_t x
 
int32_t y
 
int32_t z
 

Friends

std::ostream & operator<< (std::ostream &out, const Coordinate &coord)
 Outputs the Coordinate object to an ostream.
 

Detailed Description

Represented using integers since sub-unit coordinates are not of particular relevance. Allows for operations such as addition between coordinates.

Constructor & Destructor Documentation

◆ Coordinate() [1/3]

constexpr mcpp::Coordinate::Coordinate ( int32_t  x,
int32_t  y,
int32_t  z 
)
inlineconstexpr

Constructs a Coordinate object with integer values.

Parameters
xThe x-coordinate.
yThe y-coordinate.
zThe z-coordinate.

◆ Coordinate() [2/3]

constexpr mcpp::Coordinate::Coordinate ( )
inlineconstexpr

Constructs a Coordinate object with zero values.

◆ Coordinate() [3/3]

constexpr mcpp::Coordinate::Coordinate ( double  x,
double  y,
double  z 
)
inlineconstexpr

Constructs a Coordinate object with double values.

Parameters
xThe x-coordinate as a double.
yThe y-coordinate as a double.
zThe z-coordinate as a double.

Member Function Documentation

◆ operator!=()

bool mcpp::Coordinate::operator!= ( const Coordinate obj) const

Checks if two Coordinate objects are not equal.

Parameters
objThe Coordinate object to compare with.
Returns
True if the coordinates are not equal, false otherwise.

◆ operator+()

Coordinate mcpp::Coordinate::operator+ ( const Coordinate obj) const

Adds two Coordinate objects.

Parameters
objThe Coordinate object to add.
Returns
A new Coordinate object representing the sum of the two coordinates.

◆ operator-()

Coordinate mcpp::Coordinate::operator- ( const Coordinate obj) const

Subtracts one Coordinate object from another.

Parameters
objThe Coordinate object to subtract.
Returns
A new Coordinate object representing the difference between the two coordinates.

◆ operator==()

bool mcpp::Coordinate::operator== ( const Coordinate obj) const

Checks if two Coordinate objects are equal.

Parameters
objThe Coordinate object to compare with.
Returns
True if the coordinates are equal, false otherwise.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const Coordinate coord 
)
friend

Outputs the Coordinate object to an ostream.

Parameters
outThe output stream.
coordThe Coordinate object to output.
Returns
The output stream with the Coordinate object's values.

Member Data Documentation

◆ x

int32_t mcpp::Coordinate::x

◆ y

int32_t mcpp::Coordinate::y

◆ z

int32_t mcpp::Coordinate::z

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