A generic 3D coordinate class for robotics, navigation, and spatial calculations.
More...
|
|
| Coordinate (T x, T y, T z=0) |
| |
|
| Coordinate (const Coordinate &other) |
| | Copy constructor.
|
| |
|
| Coordinate (Distance x, Distance y, Distance z=0) |
| | Construct from Distance objects.
|
| |
| DistanceM | distance (const Coordinate &other, DistanceUnit unit=DistanceUnit::M) const |
| |
| float | bearing (const Coordinate &other, AngleUnit unit=AngleUnit::DEG) const |
| |
|
float | elevation (const Coordinate &other, AngleUnit unit=AngleUnit::DEG) const |
| | Calculate the elevation angle from this coordinate to another.
|
| |
| Coordinate | navigate (Distance distance, Angle bearing, Distance altDiff=0) const |
| |
| Coordinate | navigate (DistanceM distanceM, float headingDegrees, float altDiffM=0) const |
| |
| DistanceM | altitudeDifference (const Coordinate &other) const |
| |
| bool | equals (const Coordinate &other, DistanceM limit) const |
| |
| bool | equalsWithAltitude (const Coordinate &other, DistanceM limit, DistanceM altLimit) const |
| |
| Coordinate | operator+ (const Coordinate &other) const |
| |
|
Coordinate | operator- (const Coordinate &other) const |
| | Calculate new coordinate by subtracting offset in other from this one.
|
| |
|
void | operator+= (const Coordinate &other) |
| | Add offset defined in other to current coordinate.
|
| |
|
void | operator-= (const Coordinate &other) |
| | Subtract offset in other from this one.
|
| |
|
void | operator= (const Coordinate &other) |
| | Assign values from another coordinate.
|
| |
|
bool | operator== (const Coordinate< T > &other) const |
| | Equality operators for use in std::unordered_map and comparisons.
|
| |
|
bool | operator!= (const Coordinate< T > &other) const |
| |
|
bool | operator< (const Coordinate &other) const |
| | Lexicographical comparison for STL containers (priority_queue, set, etc.)
|
| |
| std::string | toString () const |
| | Convert coordinate to string representation.
|
| |
| bool | fromString (const std::string &str) |
| | Parse coordinate from string representation.
|
| |
|
void | setValues (T newX, T newY, T newZ=0) |
| | Set coordinate values from numeric types.
|
| |
|
void | setValues (Distance newX, Distance newY, Distance newZ=0) |
| | Set coordinate values from Distance objects.
|
| |
| std::vector< Coordinate< T > > | interpolateTo (const Coordinate< T > &target, T resolution) |
| | Interpolate points between source and target with a defined resolution.
|
| |
|
std::vector< Coordinate< T > > | interpolateTo (const Coordinate< T > &target, Distance resolution) |
| | Interpolate points between source and target with Distance resolution.
|
| |
|
const char * | getTypeName () const |
| | Get the type name string.
|
| |
| virtual std::string | toString () const =0 |
| |
|
const char * | toCString () const |
| |
| virtual bool | fromString (const std::string &in)=0 |
| |
|
virtual bool | fromString (const char *in) |
| |
|
size_t | writeTo (Print &out) const |
| |
|
size_t | readFrom (Stream &in) |
| |
template<typename T = DistanceM>
class tinyrobotics::Coordinate< T >
A generic 3D coordinate class for robotics, navigation, and spatial calculations.
The Coordinate class represents a point in 3D space with x, y, and z values (in meters by default). It is templated to support different numeric types (e.g., float, double) for precision or memory needs. This class provides essential geometric operations for robotics, mapping, and navigation, including:
- Calculating Euclidean distance to another coordinate (with selectable units)
- Computing the horizontal bearing (heading) and vertical elevation angle to another point
- Navigating to a new coordinate given a distance, heading, and altitude change
- Comparing coordinates for proximity within a specified tolerance
- Basic arithmetic operations (addition, subtraction, assignment)
- Serialization and deserialization to/from string for storage or communication
The x, y, and z values are interpreted as meters in a local or global Cartesian frame.
- Template Parameters
-
| T | Numeric type for coordinates (default: float) |
Example usage:
float dist = a.distance(b);
float elev = a.elevation(b);
A generic 3D coordinate class for robotics, navigation, and spatial calculations.
Definition: Coordinate.h:57
float bearing(const Coordinate &other, AngleUnit unit=AngleUnit::DEG) const
Definition: Coordinate.h:88
Coordinate navigate(Distance distance, Angle bearing, Distance altDiff=0) const
Definition: Coordinate.h:105
This class is suitable for use in path planning, SLAM, mapping, sensor fusion, and any application requiring 2D or 3D spatial representation and geometric calculations.