80 return TPoint2D_<U>(
static_cast<U
>(this->
x), static_cast<U>(this->
y));
93 throw std::out_of_range(
"index out of range");
106 throw std::out_of_range(
"index out of range");
113 template <
typename U>
117 v[0] =
static_cast<U
>(this->
x);
118 v[1] =
static_cast<U
>(this->
y);
154 return {this->
x + p.
x, this->
y + p.
y};
159 return {this->
x - p.
x, this->
y - p.
y};
164 return {d * this->
x, d * this->
y};
169 return {this->
x / d, this->
y / d};
202 T
sqrNorm()
const {
return this->
x * this->
x + this->
y * this->
y; }
222 template <
typename T>
225 return (p1.
x == p2.
x) && (p1.
y == p2.
y);
229 template <
typename T>
232 return (p1.
x != p2.
x) || (p1.
y != p2.
y);
TPoint2D_(const TPoint2D_data< U > &p)
Explicit constructor from coordinates.
A compile-time fixed-size numeric matrix container.
TPoint2D_< double > TPoint2D
Lightweight 2D point.
T & operator[](size_t i)
Coordinate access using operator[].
std::string std::string format(std::string_view fmt, ARGS &&... args)
TPoint2D_ & operator*=(T d)
std::string asString() const
Base type of all TPoseXX and TPointXX classes in mrpt::math.
TPoint2D_ & operator/=(T d)
constexpr TPoint2D_()
Default constructor.
constexpr TPoint2D_(T xx, T yy)
Constructor from coordinates.
#define ASSERT_(f)
Defines an assertion mechanism.
This base provides a set of functions for maths stuff.
constexpr TPoint2D_ operator-(const TPoint2D_ &p) const
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" ) ...
TPoint2D_(const mrpt::math::CMatrixFixed< U, 2, 1 > &m)
Constructor from column vector.
#define MRPT_DECLARE_TTYPENAME_NO_NAMESPACE(_TYPE, __NS)
Declares a typename to be "type" (without the NS prefix)
constexpr TPoint2D_ operator*(T d) const
constexpr TPoint2D_ operator+(const TPoint2D_ &p) const
constexpr bool operator==(const TPoint2D_< T > &p1, const TPoint2D_< T > &p2)
Exact comparison between 2D points.
Base template for TPoint2D and TPoint2Df.
constexpr bool operator!=(const TPoint2D_< T > &p1, const TPoint2D_< T > &p2)
Exact comparison between 2D points.
TPoint2D_ & operator+=(const TPoint2D_ &p)
TPoint2D_ & operator-=(const TPoint2D_ &p)
Provided for STL and matrices/vectors compatibility.
Base template for TPoint3D and TPoint3Df.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void asVector(std::vector< U > &v) const
Transformation into vector.
T norm() const
Point norm: |v| = sqrt(x^2+y^2)
TPoint2D_< U > cast() const
Return a copy of this object using type U for coordinates.
T sqrNorm() const
Squared norm: |v|^2 = x^2+y^2.
constexpr TPoint2D_ operator/(T d) const
bool operator<(const TPoint2D_ &p) const
static TPoint2D_ FromString(const std::string &s)
constexpr T operator[](size_t i) const
Coordinate access using operator[].
TPoint2D_< float > TPoint2Df
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" ) ...