mcpp
C++ Minecraft Library
Loading...
Searching...
No Matches
coordinate.h
Go to the documentation of this file.
1#pragma once
2
3#include <ostream>
4
9namespace mcpp {
14struct Coordinate {
15 int32_t x;
16 int32_t y;
17 int32_t z;
18
26 constexpr Coordinate(int32_t x, int32_t y, int32_t z) : x(x), y(y), z(z) {}
27
31 constexpr Coordinate() : x(0), y(0), z(0) {}
32
40 constexpr Coordinate(double x, double y, double z)
41 : x(static_cast<int>(x)), y(static_cast<int>(y)), z(static_cast<int>(z)) {}
42
50 Coordinate operator+(const Coordinate& obj) const;
51
58 bool operator==(const Coordinate& obj) const;
59
66 bool operator!=(const Coordinate& obj) const;
67
75 Coordinate operator-(const Coordinate& obj) const;
76
84 friend std::ostream& operator<<(std::ostream& out, const Coordinate& coord);
85};
86
93std::string to_string(const Coordinate& coord);
94
95} // namespace mcpp
Namespace containing all the the mcpp library classes.
Definition block.h:10
std::string to_string(const Coordinate &coord)
Convert coordinate to string representation.
Definition coordinate.h:14
Coordinate operator+(const Coordinate &obj) const
Adds two Coordinate objects.
int32_t y
Definition coordinate.h:16
Coordinate operator-(const Coordinate &obj) const
Subtracts one Coordinate object from another.
bool operator!=(const Coordinate &obj) const
Checks if two Coordinate objects are not equal.
int32_t x
Definition coordinate.h:15
constexpr Coordinate(int32_t x, int32_t y, int32_t z)
Constructs a Coordinate object with integer values.
Definition coordinate.h:26
friend std::ostream & operator<<(std::ostream &out, const Coordinate &coord)
Outputs the Coordinate object to an ostream.
constexpr Coordinate()
Constructs a Coordinate object with zero values.
Definition coordinate.h:31
constexpr Coordinate(double x, double y, double z)
Constructs a Coordinate object with double values.
Definition coordinate.h:40
int32_t z
Definition coordinate.h:17
bool operator==(const Coordinate &obj) const
Checks if two Coordinate objects are equal.