4#include "state_representation/units/Distance.hpp"
5#include "state_representation/units/Angle.hpp"
7using namespace std::chrono_literals;
9namespace state_representation::units {
13using LinearVelocity = Velocity<Distance>;
14using AngularVelocity = Velocity<Angle>;
16inline namespace literals {
22constexpr LinearVelocity
operator ""_m_s(
long double n);
29constexpr LinearVelocity
operator ""_m_h(
long double n);
36constexpr LinearVelocity
operator ""_m_ms(
long double n);
43constexpr LinearVelocity
operator ""_km_h(
long double n);
50constexpr LinearVelocity
operator ""_km_s(
long double n);
57constexpr LinearVelocity
operator ""_km_ms(
long double n);
64constexpr LinearVelocity
operator ""_mm_h(
long double n);
71constexpr AngularVelocity
operator ""_rad_s(
long double n);
78constexpr AngularVelocity
operator ""_deg_s(
long double n);
91 constexpr Velocity(
long double n = 0.0);
216 return lhs.value / rhs.value;
234 template<
class Rep,
class DurationRatio>
235 friend constexpr Velocity<T> operator/(
const T& lhs,
const std::chrono::duration<Rep, DurationRatio>& rhs);
253 this->value = -this->value;
259 this->value = this->value + rhs.value;
272 this->value = this->value - rhs.value;
285 this->value = this->value * lambda;
298 this->value = this->value / lambda;
311 return (abs(this->value - rhs.value) < 1e-4);
316 return !((*this) == rhs);
321 return ((this->value - rhs.value) > 1e-4);
326 return (((*
this) > rhs) or ((*
this) == rhs));
331 return ((rhs.value - this->value) > 1e-4);
336 return (((*
this) < rhs) or ((*
this) == rhs));
339template<
class T,
class Rep,
class DurationRatio>
340constexpr Velocity<T> operator/(
const T&
dist,
const std::chrono::duration<Rep, DurationRatio>& rhs) {
341 const auto rhsInSeconds = std::chrono::duration_cast<std::chrono::seconds>(rhs);
345inline namespace literals {
352constexpr LinearVelocity
operator ""_m_h(
long double n) {
358constexpr LinearVelocity
operator ""_m_ms(
long double n) {
364constexpr LinearVelocity
operator ""_km_h(
long double n) {
370constexpr LinearVelocity
operator ""_km_s(
long double n) {
376constexpr LinearVelocity
operator ""_km_ms(
long double n) {
382constexpr LinearVelocity
operator ""_mm_h(
long double n) {
388constexpr AngularVelocity
operator ""_rad_s(
long double n) {
394constexpr AngularVelocity
operator ""_deg_s(
long double n) {
constexpr bool operator==(const Velocity< T > &rhs) const
Overload the == operator.
constexpr Velocity< T > & operator/=(double lambda)
Overload the /= operator with a scalar.
constexpr Velocity(long double n=0.0)
Constructor with a value in the base unit of T.
constexpr bool operator!=(const Velocity< T > &rhs) const
Overload the != operator.
constexpr bool operator<(const Velocity< T > &rhs) const
Overload the < operator.
constexpr Velocity< T > operator+(const Velocity< T > &rhs) const
Overload the + operator.
friend constexpr Velocity< T > operator*(double lambda, const Velocity< T > &rhs)
Overload the * operator with a scalar on the left side.
constexpr Velocity< T > & operator+=(const Velocity< T > &rhs)
Overload the += operator.
constexpr Velocity< T > & operator*=(double lambda)
Overload the *= operator with a scalar.
constexpr long double get_value() const
Getter of the value attribute.
constexpr Velocity< T > & operator-()
Overload the - operator.
constexpr bool operator>=(const Velocity< T > &rhs) const
Overload the > operator.
constexpr bool operator>(const Velocity< T > &rhs) const
Overload the > operator.
friend constexpr double operator/(const Velocity< T > &lhs, const Velocity< T > &rhs)
Overload the / operator between two Velocitys.
constexpr Velocity< T > & operator-=(const Velocity< T > &rhs)
Overload the -= operator.
constexpr bool operator<=(const Velocity< T > &rhs) const
Overload the < operator.
double dist(const CartesianState &s1, const CartesianState &s2, const CartesianStateVariable &state_variable_type=CartesianStateVariable::ALL)
Compute the distance between two Cartesian states.