struct mrpt::math::TPose2D

Lightweight 2D pose.

Allows coordinate access using [] operator.

See also:

mrpt::poses::CPose2D

#include <mrpt/math/TPose2D.h>

struct TPose2D:
    public mrpt::math::TPoseOrPoint,
    public mrpt::math::internal::ProvideStaticResize
{
    // enums

    enum
    {
        static_size = 3,
    };

    //
fields

    double x {.0};
    double y {.0};
    double phi {.0};

    // construction

    TPose2D(const TPoint2D& p);
    TPose2D(const TPoint3D& p);
    TPose2D(const TPose3D& p);
    TPose2D(double xx, double yy, double Phi);
    TPose2D();

    //
methods

    static constexpr TPose2D Identity();
    static TPose2D FromString(const std::string& s);
    double& operator [] (size_t i);
    constexpr double operator [] (size_t i) const;
    void asVector(std::vector<double>& v) const;
    void asString(std::string& s) const;
    std::string asString() const;
    mrpt::math::TPose2D operator + (const mrpt::math::TPose2D& b) const;
    mrpt::math::TPose2D operator - (const mrpt::math::TPose2D& b) const;
    mrpt::math::TPoint2D composePoint(const TPoint2D l) const;
    mrpt::math::TPoint2D operator + (const mrpt::math::TPoint2D& b) const;
    mrpt::math::TPoint2D inverseComposePoint(const TPoint2D g) const;
    double norm() const;
    void normalizePhi();
    void fromString(const std::string& s);
};

Inherited Members

public:
    //
methods

    void resize(std::size_t n);

Fields

double x {.0}

X,Y coordinates.

double phi {.0}

Orientation (rads)

Construction

TPose2D(const TPoint2D& p)

Implicit constructor from TPoint2D.

Zeroes the phi coordinate.

See also:

TPoint2D

TPose2D(const TPoint3D& p)

Constructor from TPoint3D, losing information.

Zeroes the phi coordinate.

See also:

TPoint3D

TPose2D(const TPose3D& p)

Constructor from TPose3D, losing information.

The phi corresponds to the original pose’s yaw.

See also:

TPose3D

TPose2D(double xx, double yy, double Phi)

Constructor from coordinates.

TPose2D()

Default fast constructor.

Initializes to zeros.

Methods

static constexpr TPose2D Identity()

Returns the identity transformation.

double& operator [] (size_t i)

Coordinate access using operator[].

Order: x,y,phi

constexpr double operator [] (size_t i) const

Coordinate access using operator[].

Order: x,y,phi

void asVector(std::vector<double>& v) const

Transformation into vector.

void asString(std::string& s) const

Returns a human-readable textual representation of the object (eg: “[x y yaw]”, yaw in degrees)

See also:

fromString

mrpt::math::TPose2D operator + (const mrpt::math::TPose2D& b) const

Operator “oplus” pose composition: “ret=this oplus b”.

See also:

CPose2D

mrpt::math::TPose2D operator - (const mrpt::math::TPose2D& b) const

Operator “ominus” pose composition: “ret=this ominus b”.

See also:

CPose2D

double norm() const

Returns the norm of the (x,y) vector (phi is not used)

void normalizePhi()

Forces “phi” to be in the range [-pi,pi].

void fromString(const std::string& s)

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

Parameters:

std::exception

On invalid format

See also:

asString