class mrpt::poses::CPoint2D

Overview

A class used to store a 2D point.

For a complete description of Points/Poses, see mrpt::poses::CPoseOrPoint, or refer to the 2D/3D Geometry tutorial in the wiki.

_images/CPoint2D.gif

See also:

CPoseOrPoint, CPose, CPoint

#include <mrpt/poses/CPoint2D.h>

class CPoint2D:
    public mrpt::poses::CPoint,
    public mrpt::serialization::CSerializable
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::poses ::CPoint2D> Ptr;
    typedef std::shared_ptr<const mrpt::poses ::CPoint2D> ConstPtr;
    typedef std::unique_ptr<mrpt::poses ::CPoint2D> UniquePtr;
    typedef std::unique_ptr<const mrpt::poses ::CPoint2D> ConstUniquePtr;
    typedef double value_type;
    typedef double& reference;
    typedef double const_reference;
    typedef std::size_t size_type;
    typedef std::ptrdiff_t difference_type;

    // enums

    enum
    {
        is_3D_val = 0,
    };

    enum
    {
        is_PDF_val = 0,
    };

    // fields

    static constexpr const char* className = "mrpt::poses" "::" "CPoint2D";
    static constexpr std::size_t static_size = 2;
    mrpt::math::CVectorFixedDouble<2> m_coords;

    // construction

    CPoint2D();
    CPoint2D(double x, double y);

    template <class OTHERCLASS, std::size_t DIM2>
    CPoint2D(const CPoseOrPoint<OTHERCLASS, DIM2>& b);

    CPoint2D(const mrpt::math::TPoint2D& o);
    CPoint2D(const mrpt::math::TPoint3D& o);

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    static constexpr size_type size();
    static constexpr bool empty();
    static constexpr size_type max_size();
    static void resize(size_t n);
    static constexpr bool is_3D();
    static constexpr bool is_PDF();
    mrpt::math::TPoint2D asTPoint() const;
    void asVector(vector_t& v) const;
    CPoint2D operator - (const CPose2D& b) const;
};

Inherited Members

public:
    // typedefs

    typedef mrpt::math::CVectorFixedDouble<static_cast<mrpt::math::matrix_dim_t>(DIM)> vector_t;
    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;

    // methods

    double& x();
    double& y();
    void x(const double v);
    void y(const double v);
    void x_incr(const double v);
    void y_incr(const double v);
    CPoseOrPoint& operator = (const CPoseOrPoint&);
    CPoseOrPoint& operator = (CPoseOrPoint&&);
    const DERIVEDCLASS& derived() const;
    DERIVEDCLASS& derived();

    template <class OTHERCLASS>
    void AddComponents(const OTHERCLASS& b);

    void operator *= (const double s);

    template <class MATRIX44>
    void getHomogeneousMatrix(MATRIX44& out_HM) const;

    virtual std::string asString() const;
    void fromString(const std::string& s);
    double x() const;
    double y() const;

    template <class OTHERCLASS, std::size_t DIM2>
    double sqrDistanceTo(const CPoseOrPoint<OTHERCLASS, DIM2>& b) const;

    template <class OTHERCLASS, std::size_t DIM2>
    double distanceTo(const CPoseOrPoint<OTHERCLASS, DIM2>& b) const;

    double distanceTo(const mrpt::math::TPoint3D& b) const;
    double distance2DToSquare(double ax, double ay) const;
    double distance3DToSquare(double ax, double ay, double az) const;
    double distance2DTo(double ax, double ay) const;
    double distance3DTo(double ax, double ay, double az) const;
    double norm() const;
    vector_t asVectorVal() const;

    template <class MATRIX44>
    MATRIX44 getHomogeneousMatrixVal() const;

    template <class MATRIX44>
    void getInverseHomogeneousMatrix(MATRIX44& out_HM) const;

    template <class MATRIX44>
    MATRIX44 getInverseHomogeneousMatrixVal() const;

    static bool is3DPoseOrPoint();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();

Typedefs

typedef std::shared_ptr<mrpt::poses ::CPoint2D> Ptr

A type for the associated smart pointer.

typedef double value_type

The type of the elements.

Fields

mrpt::math::CVectorFixedDouble<2> m_coords

[x,y]

Construction

CPoint2D(double x, double y)

Constructor for initializing point coordinates.

template <class OTHERCLASS, std::size_t DIM2>
CPoint2D(const CPoseOrPoint<OTHERCLASS, DIM2>& b)

Constructor from x/y coordinates given from other pose.

CPoint2D(const mrpt::math::TPoint2D& o)

Explicit constructor from lightweight type.

CPoint2D(const mrpt::math::TPoint3D& o)

Explicit constructor from lightweight type (loses the z coord).

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

void asVector(vector_t& v) const

Return the pose or point as a 2x1 vector [x, y]’.

CPoint2D operator - (const CPose2D& b) const

The operator D=”this”-b is the pose inverse compounding operator, the resulting points “D” fulfils: “this” = b + D, so that: b == a + (b-a)