mcpp
C++ Minecraft Library
mcpp::Coordinate Struct Reference

#include <util.h>

Public Member Functions

 Coordinate (int x=0, int y=0, int z=0)
 Constructs a Coordinate object with integer values. More...
 
 Coordinate (double x, double y, double z)
 Constructs a Coordinate object with double values. More...
 
Coordinate operator+ (const Coordinate &obj) const
 Adds two Coordinate objects. More...
 
bool operator== (const Coordinate &obj) const
 Checks if two Coordinate objects are equal. More...
 
bool operator!= (const Coordinate &obj) const
 Checks if two Coordinate objects are not equal. More...
 
Coordinate operator- (const Coordinate &obj) const
 Subtracts one Coordinate object from another. More...
 
Coordinate clone () const
 Creates a copy of the Coordinate object. More...
 

Public Attributes

int x
 
int y
 
int z
 

Friends

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

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/2]

mcpp::Coordinate::Coordinate ( int  x = 0,
int  y = 0,
int  z = 0 
)
explicit

Constructs a Coordinate object with integer values.

Parameters
xThe x-coordinate. Default is 0.
yThe y-coordinate. Default is 0.
zThe z-coordinate. Default is 0.

◆ Coordinate() [2/2]

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

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

◆ clone()

Coordinate mcpp::Coordinate::clone ( ) const

Creates a copy of the Coordinate object.

Returns
A new Coordinate object that is a copy of the current object.

◆ 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 Function 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

int mcpp::Coordinate::x

◆ y

int mcpp::Coordinate::y

◆ z

int mcpp::Coordinate::z

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