Class GridCoord1D
Defined in File grid1d.h
Inheritance Relationships
Base Type
public kami::GridCoord
(Class GridCoord)
Class Documentation
-
class GridCoord1D : public kami::GridCoord
One-dimensional coordinates.
Public Functions
-
explicit GridCoord1D(int x_coord)
Constructor for one-dimensional coordinates.
-
int x() const
Return the
x
coordinate.
-
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. There are three options provided by the
GridDistanceType
class. However, of the three distance types provided, all provide the same result so the value is ignored and the single result is returned.However, the coordinate class is not aware of the properties of the
Grid1D
it is operating on. Accordingly, if the direct path is measured, without accounting for and toroidal wrapping of the underlyingGrid1D
.- Parameters
p – the point to measure the distance to
- Returns
the distance as a
double
Friends
-
friend bool operator==(const GridCoord1D &lhs, const GridCoord1D &rhs)
Test if two coordinates are equal.
-
friend bool operator!=(const GridCoord1D &lhs, const GridCoord1D &rhs)
Test if two coordinates are not equal.
-
friend std::ostream &operator<<(std::ostream &lhs, const GridCoord1D &rhs)
Output a given coordinate to the specified stream.
-
inline friend GridCoord1D operator+(const GridCoord1D &lhs, const GridCoord1D &rhs)
Add two coordinates together.
-
inline friend GridCoord1D operator-(const GridCoord1D &lhs, const GridCoord1D &rhs)
Subtract one coordinate from another.
-
inline friend GridCoord1D operator*(const GridCoord1D &lhs, 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 GridCoord1D operator*(double lhs, const GridCoord1D &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
.
-
explicit GridCoord1D(int x_coord)