template struct mrpt::math::TPoint2D_

Base template for TPoint2D and TPoint2Df.

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

#include <mrpt/math/TPoint2D.h>

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

    enum
    {
        static_size = 2,
    };

    //
fields

    T x;

    // construction

    TPoint2D_();
    TPoint2D_(T xx, T yy);

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

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

    TPoint2D_(const TPose2D& p);
    TPoint2D_(const TPoint3D_<T>& p);
    TPoint2D_(const TPose3D& p);

    //
methods

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

    T& operator [] (size_t i);
    constexpr T operator [] (size_t i) const;

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

    template <typename Vector>
    Vector asVector() const;

    bool operator < (const TPoint2D_& p) const;
    TPoint2D_& operator += (const TPoint2D_& p);
    TPoint2D_& operator -= (const TPoint2D_& p);
    TPoint2D_& operator *= (T d);
    TPoint2D_& operator/= (T d);
    constexpr TPoint2D_ operator + (const TPoint2D_& p) const;
    constexpr TPoint2D_ operator - (const TPoint2D_& p) const;
    constexpr TPoint2D_ operator * (T d) const;
    constexpr TPoint2D_ operator/ (T d) const;
    void asString(std::string& s) const;
    std::string asString() const;
    void fromString(const std::string& s);
    T sqrNorm() const;
    T norm() const;
    TPoint2D_<T> unitarize() const;

    template <typename Vector>
    static TPoint2D FromVector(const Vector& v);

    static TPoint2D_ FromString(const std::string& s);
};

Inherited Members

public:
    //
fields

    T y;

    //
methods

    void resize(std::size_t n);

Fields

T x

X,Y coordinates.

Construction

TPoint2D_()

Default constructor.

Initializes to zeros

TPoint2D_(T xx, T yy)

Constructor from coordinates

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

Explicit constructor from coordinates.

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

Constructor from column vector.

TPoint2D_(const TPose2D& p)

Constructor from TPose2D, discarding phi.

See also:

TPose2D

TPoint2D_(const TPoint3D_<T>& p)

Constructor from TPoint3D, discarding z.

See also:

TPoint3D

TPoint2D_(const TPose3D& p)

Constructor from TPose3D, discarding z and the angular coordinates.

See also:

TPose3D

Methods

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

Return a copy of this object using type U for coordinates.

T& operator [] (size_t i)

Coordinate access using operator[].

Order: x,y

constexpr T operator [] (size_t i) const

Coordinate access using operator[].

Order: x,y

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

Gets the pose as a vector of doubles.

Parameters:

Vector

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

template <typename Vector>
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.

void asString(std::string& s) const

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

See also:

fromString

void fromString(const std::string& s)

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

Parameters:

std::exception

On invalid format

See also:

asString

T sqrNorm() const

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

T norm() const

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

TPoint2D_<T> unitarize() const

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

template <typename Vector>
static TPoint2D FromVector(const Vector& v)

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

Parameters:

Vector

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