97 return x == other.
x &&
y == other.
y;
106 return x != other.
x ||
y != other.
y;
150 return "[" + std::to_string(
x) +
"," + std::to_string(
y) +
"]";
168 std::string
x = str.substr(1, str.find(
",") - 1);
169 std::string
y = str.substr(str.find(
",") + 1, str.find(
"]") - str.find(
",") - 1);
219 explicit Coordinate3D(std::vector<int> xyz) :
x(xyz.at(0)),
y(xyz.at(1)),
z(xyz.at(2)) {}
225 explicit Coordinate3D(std::array<int, 3> xyz) :
x(xyz.at(0)),
y(xyz.at(1)),
z(xyz.at(2)) {}
231 explicit Coordinate3D(std::vector<double> xyz) :
x(xyz.at(0)),
y(xyz.at(1)),
z(xyz.at(2)) {}
237 explicit Coordinate3D(std::array<double, 3> xyz) :
x(xyz.at(0)),
y(xyz.at(1)),
z(xyz.at(2)) {}
244 return x *
x +
y *
y +
z *
z;
253 return x == other.
x &&
y == other.
y &&
z == other.
z;
262 return x != other.
x ||
y != other.
y ||
z != other.
z;
306 return "[" + std::to_string(
x) +
"," + std::to_string(
y) +
"," + std::to_string(
z) +
"]";
324 std::string
x = str.substr(1, str.find(
",") - 1);
325 std::string
y = str.substr(str.find(
",") + 1, str.rfind(
",") - str.find(
",") - 1);
326 std::string
z = str.substr(str.rfind(
",") + 1, str.find(
"]") - str.rfind(
",") - 1);
Definition coordinate.hpp:28
Coordinate2D(std::vector< int > xy)
Definition coordinate.hpp:63
double getMagnitude() const
Definition coordinate.hpp:87
Coordinate2D(std::array< int, 2 > xy)
Definition coordinate.hpp:69
static Coordinate2D from_string(const std::string &str)
Definition coordinate.hpp:167
Coordinate2D(double x, double y)
Definition coordinate.hpp:57
bool operator==(const Coordinate2D &other) const
Definition coordinate.hpp:96
std::ostream & operator<<(std::ostream &strm)
Definition coordinate.hpp:158
double y
Definition coordinate.hpp:38
Coordinate2D(std::vector< double > xy)
Definition coordinate.hpp:75
Coordinate2D()
Definition coordinate.hpp:43
Coordinate2D operator/(int scalar) const
Definition coordinate.hpp:141
bool operator!=(const Coordinate2D &other) const
Definition coordinate.hpp:105
Coordinate2D operator+(const Coordinate2D &other) const
Definition coordinate.hpp:114
Coordinate2D operator-(const Coordinate2D &other) const
Definition coordinate.hpp:123
std::string to_string() const
Definition coordinate.hpp:149
double x
Definition coordinate.hpp:33
Coordinate2D operator*(int scalar) const
Definition coordinate.hpp:132
Coordinate2D(int x, int y)
Definition coordinate.hpp:50
Coordinate2D(std::array< double, 2 > xy)
Definition coordinate.hpp:81
Definition coordinate.hpp:177
std::string to_string() const
Definition coordinate.hpp:305
double x
Definition coordinate.hpp:182
double z
Definition coordinate.hpp:192
Coordinate3D operator/(int scalar) const
Definition coordinate.hpp:297
Coordinate3D()
Definition coordinate.hpp:197
Coordinate3D(double x, double y, double z)
Definition coordinate.hpp:213
Coordinate3D(std::array< int, 3 > xyz)
Definition coordinate.hpp:225
Coordinate3D(int x, int y, int z)
Definition coordinate.hpp:205
Coordinate3D operator+(const Coordinate3D &other) const
Definition coordinate.hpp:270
Coordinate3D operator-(const Coordinate3D &other) const
Definition coordinate.hpp:279
Coordinate3D(std::vector< int > xyz)
Definition coordinate.hpp:219
static Coordinate3D from_string(const std::string &str)
Definition coordinate.hpp:323
std::ostream & operator<<(std::ostream &strm)
Definition coordinate.hpp:314
double getMagnitude() const
Definition coordinate.hpp:243
Coordinate3D operator*(int scalar) const
Definition coordinate.hpp:288
double y
Definition coordinate.hpp:187
Coordinate3D(std::vector< double > xyz)
Definition coordinate.hpp:231
Coordinate3D(std::array< double, 3 > xyz)
Definition coordinate.hpp:237
bool operator==(const Coordinate3D &other) const
Definition coordinate.hpp:252
bool operator!=(const Coordinate3D &other) const
Definition coordinate.hpp:261
Definition coordinate.hpp:11
virtual double getMagnitude() const =0
virtual std::string to_string() const =0