Class GridCoord2D
Defined in File grid2d.h
Inheritance Relationships
Base Type
public kami::GridCoord
(Class GridCoord)
Class Documentation
-
class GridCoord2D : public kami::GridCoord
Two-dimensional coordinates.
Public Functions
-
GridCoord2D(int x_coord, int y_coord)
Constructor for two-dimensional coordinates.
-
int x() const
Get the coordinate in the first dimension or
x
.
-
int y() const
Get the coordinate in the second dimension or
y
.
-
virtual std::string to_string() const override
Convert the coordinate to a human-readable string.
- Returns
a human-readable form of the
Coord
asstd::string
.
Find the distance between two points.
Find the distance between two points using the specified metric.
However, the coordinate class is not aware of the properties of the
Grid2D
it is operating on. Accordingly, if the direct path is measured, without accounting for and toroidal wrapping of the underlyingGrid2D
.- Parameters
p – the point to measure the distance to
- Returns
the distance as a
double
Find the distance between two points.
Find the distance between two points using the specified metric. There are three options provided by the
GridDistanceType
class.However, the coordinate class is not aware of the properties of the
Grid2D
it is operating on. Accordingly, if the direct path is measured, without accounting for and toroidal wrapping of the underlyingGrid2D
.- Parameters
p – the point to measure the distance to
distance_type – specify the distance type
- Returns
the distance as a
double
Protected Functions
Find the distance between two points using the Chebyshev metric.
- Parameters
p – the point to measure the distance to
- Returns
the distance as a
double
Find the distance between two points using the Euclidean metric.
- Parameters
p – the point to measure the distance to
- Returns
the distance as a
double
Find the distance between two points using the Manhattan metric.
- Parameters
p – the point to measure the distance to
- Returns
the distance as a
double
Friends
-
friend bool operator==(const GridCoord2D&, const GridCoord2D&)
Test if two coordinates are equal.
-
friend bool operator!=(const GridCoord2D&, const GridCoord2D&)
Test if two coordinates are not equal.
-
friend std::ostream &operator<<(std::ostream&, const GridCoord2D&)
Output a given coordinate to the specified stream.
-
inline friend GridCoord2D operator+(const GridCoord2D &lhs, const GridCoord2D &rhs)
Add two coordinates together.
-
inline friend GridCoord2D operator-(const GridCoord2D &lhs, const GridCoord2D &rhs)
Subtract one coordinate from another.
-
inline friend GridCoord2D operator*(const GridCoord2D &lhs, const double rhs)
Multiply a coordinate by a scalar.
If any component of the resulting value is not a whole number, it is truncated following the same rules as
int
.
-
inline friend GridCoord2D operator*(const double lhs, const GridCoord2D &rhs)
Multiply a coordinate by a scalar.
If any component of the resulting value is not a whole number, it is truncated following the same rules as
int
.
-
GridCoord2D(int x_coord, int y_coord)