Template Struct TPoint2D_

Inheritance Relationships

Base Types

Struct Documentation

template<typename T>
struct TPoint2D_ : public mrpt::math::TPoseOrPoint, public mrpt::math::TPoint2D_data<T>, public mrpt::math::internal::ProvideStaticResize<TPoint2D_<T>>

Base template for TPoint2D (double) and TPoint2Df (float).

Represents a point (or free vector) in the 2D Euclidean space R^2. Coordinates are stored as (x, y).

This is a lightweight POD-like type intended for storage and arithmetic. When pose-point composition (i.e. applying an SE(2) rigid transformation to a point) is needed, use mrpt::poses::CPose2D or mrpt::math::TPose2D instead.

Forward declarations of all mrpt::math classes related to poses and points

Note

TVector2D is a type alias for TPoint2D (both represent elements of R^2; the alias is provided for semantic clarity when the object is a free vector rather than a position).

Public Functions

inline constexpr TPoint2D_()

Default constructor. Initializes to zeros

inline constexpr TPoint2D_(T xx, T yy)

Constructor from coordinates

template<typename U>
inline TPoint2D_(const TPoint2D_data<U> &p)

Explicit constructor from coordinates.

template<typename U>
inline explicit TPoint2D_(const mrpt::math::CMatrixFixed<U, 2, 1> &m)

Constructor from column vector.

explicit TPoint2D_(const TPose2D &p)

Constructor from TPose2D, retaining only the translational part (x,y); phi is discarded.

See also

TPose2D

explicit TPoint2D_(const TPoint3D_<T> &p)

Constructor from TPoint3D, retaining only (x,y); z is discarded.

See also

TPoint3D

explicit TPoint2D_(const TPose3D &p)

Constructor from TPose3D, retaining only the translational (x,y) part; z and all angular coordinates are discarded.

See also

TPose3D

template<typename U>
inline TPoint2D_<U> cast() const

Return a copy of this object using type U for coordinates

inline T &operator[](size_t i)

Coordinate access using operator[]. Order: x,y

inline constexpr T operator[](size_t i) const

Coordinate access using operator[]. Order: x,y

template<typename Vector>
inline void asVector(Vector &v) const

Gets the pose as a vector of doubles.

Template Parameters:

Vector – It can be std::vector<double>, Eigen::VectorXd, etc.

template<typename Vector>
inline Vector asVector() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool operator<(const TPoint2D_ &p) const
inline TPoint2D_ &operator+=(const TPoint2D_ &p)
inline TPoint2D_ &operator-=(const TPoint2D_ &p)
inline TPoint2D_ &operator*=(T d)
inline TPoint2D_ &operator/=(T d)
inline constexpr TPoint2D_ operator+(const TPoint2D_ &p) const
inline constexpr TPoint2D_ operator-(const TPoint2D_ &p) const
inline constexpr TPoint2D_ operator*(T d) const
inline constexpr TPoint2D_ operator/(T d) const
inline void asString(std::string &s) const

Returns a human-readable textual representation of the object (eg: “[0.02 1.04]” )

See also

fromString

inline std::string asString() const
void fromString(const std::string &s)

Set the current object value from a string generated by ‘asString’ (eg: “[0.02 1.04]” )

See also

asString

Throws:

std::exception – On invalid format

inline T sqrNorm() const

Squared norm: |v|^2 = x^2+y^2

inline T norm() const

Point norm: |v| = sqrt(x^2+y^2)

inline TPoint2D_<T> unitarize() const

Returns this vector with unit length: v/norm(v)

Public Static Functions

template<typename Vector>
static inline TPoint2D_<T> FromVector(const Vector &v)

Builds from the first 2 elements of a vector-like object: [x y]

Template Parameters:

Vector – It can be std::vector<double>, Eigen::VectorXd, etc.

static inline TPoint2D_ FromString(const std::string &s)

Public Static Attributes

static constexpr std::size_t static_size = 2