Class GridCoord1D

Inheritance Relationships

Base Type

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 as std::string.

virtual double distance(std::shared_ptr<Coord> &p) const override

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 underlying Grid1D.

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.