RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
Point.hpp
1#pragma once
2#include <optional>
3
4#include "RaidZeroLib/api/Units/Units.hpp"
5
6namespace rz {
7
8class Rotation;
9
21class Point {
22 public:
26 constexpr Point() noexcept = default;
27
34 Point(Length x, Length y) noexcept;
35
45 Point(Length magnitude, const Rotation& rotation) noexcept;
46
52 Length X() const noexcept;
53
59 Length Y() const noexcept;
60
67 Point operator+(const Point& rhs) const noexcept;
68
75 Point operator-(const Point& rhs) const noexcept;
76
82 Point operator-() const noexcept;
83
90 Point operator*(double scalar) const noexcept;
91
100 Point operator/(double scalar) const noexcept;
101
109 Angle theta() const noexcept;
110
116 Length mag() const noexcept;
117
124 Length distTo(const Point& rhs) const noexcept;
125
134 Angle angleTo(const Point& rhs) const noexcept;
135
142 Area dot(const Point& rhs) const noexcept;
143
155 Area wedge(const Point& rhs) const noexcept;
156
168 Point project(const Point& rhs) const noexcept;
169
178 Point rotateBy(const Rotation& rhs) const noexcept;
179
186 bool isApprox(const Point& rhs) const noexcept;
187
188 private:
189 Length x = au::ZERO;
190 Length y = au::ZERO;
191};
192
206Length circumradius(const Point& A, const Point& B, const Point& C) noexcept;
207
224std::optional<double> circleLineIntersection(const Point& start, const Point& end, const Point& center,
225 Length radius) noexcept;
226
227} // namespace rz
Immutable 2D point / vector with unit-safe Cartesian coordinates.
Definition Point.hpp:21
bool isApprox(const Point &rhs) const noexcept
Approximate equality in Euclidean metric.
Length mag() const noexcept
Magnitude (Euclidean norm).
Length distTo(const Point &rhs) const noexcept
Euclidean distance to another point.
Point rotateBy(const Rotation &rhs) const noexcept
Rotates this point by a Rotation about the origin.
Length Y() const noexcept
Y coordinate.
Point project(const Point &rhs) const noexcept
Projection of this vector onto another.
Angle theta() const noexcept
Direction (heading) of the vector in radians.
Area dot(const Point &rhs) const noexcept
Dot (inner) product.
Area wedge(const Point &rhs) const noexcept
2D wedge (scalar cross) product.
Angle angleTo(const Point &rhs) const noexcept
Signed smallest-angle direction from this point’s heading to another’s.
constexpr Point() noexcept=default
Constructs the origin (0 m, 0 m).
Length X() const noexcept
X coordinate.
Immutable planar rotation about the Z axis.
Definition Rotation.hpp:16
Length circumradius(const Point &A, const Point &B, const Point &C) noexcept
Circumradius of the triangle defined by three points.
std::optional< double > circleLineIntersection(const Point &start, const Point &end, const Point &center, Length radius) noexcept
Intersection of a circle with a line segment.
void start(RobotConfig config)
Starts RaidZeroLib on the brain. Call once from initialize().
au::QuantityD< au::Squared< au::Meters > > Area
Definition Units.hpp:10
au::QuantityD< au::Radians > Angle
Definition Units.hpp:13
au::QuantityD< au::Meters > Length
Definition Units.hpp:9
Definition DriverControl.hpp:11