template class mrpt::poses::CPoint

Overview

A base class for representing a point in 2D or 3D.

For more information refer to the 2D/3D Geometry tutorial online. This class is based on the CRTP design pattern

See also:

CPoseOrPoint, CPose

#include <mrpt/poses/CPoint.h>

template <class DERIVEDCLASS, std::size_t DIM>
class CPoint:
    public mrpt::poses::CPoseOrPoint,
    public mrpt::Stringifyable
{
public:
    // typedefs

    typedef mrpt::math::CVectorFixedDouble<DIM> vector_t;

    // methods

    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;

    virtual void setToNaN() = 0;
    static bool is3DPoseOrPoint();
};

// direct descendants

class CPoint2D;
class CPoint3D;

Inherited Members

public:
    // 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);
    const DERIVEDCLASS& derived() const;
    DERIVEDCLASS& derived();

Typedefs

typedef mrpt::math::CVectorFixedDouble<DIM> vector_t

Fixed-size vector of the correct size to hold all the coordinates of the point/pose.

Methods

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

Scalar addition of all coordinates.

This is diferent from poses/point composition, which is implemented as “+” operators in classes derived from “CPose”

void operator *= (const double s)

Scalar multiplication.

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

Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (translation+orientation).

See also:

getInverseHomogeneousMatrix

virtual std::string asString() 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

double x() const

Common members of all points & poses classes.

< Get X coord.

double y() const

< Get Y coord.

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

Returns the squared euclidean distance to another pose/point:

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

Returns the Euclidean distance to another pose/point:

double distanceTo(const mrpt::math::TPoint3D& b) const

Returns the euclidean distance to a 3D point:

double distance2DToSquare(double ax, double ay) const

Returns the squared 2D distance from this pose/point to a 2D point (ignores Z, if it exists).

double distance3DToSquare(double ax, double ay, double az) const

Returns the squared 3D distance from this pose/point to a 3D point.

double distance2DTo(double ax, double ay) const

Returns the 2D distance from this pose/point to a 2D point (ignores Z, if it exists).

double distance3DTo(double ax, double ay, double az) const

Returns the 3D distance from this pose/point to a 3D point.

double norm() const

Returns the euclidean norm of vector: \(||\mathbf{x}|| = \sqrt{x^2+y^2+z^2}\).

vector_t asVectorVal() const

Return the pose or point as a 1xN vector with all the components (see derived classes for each implementation)

template <class MATRIX44>
MATRIX44 getHomogeneousMatrixVal() const

Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (translation+orientation).

See also:

getInverseHomogeneousMatrix

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

Returns the corresponding 4x4 inverse homogeneous transformation matrix for this point or pose.

See also:

getHomogeneousMatrix

template <class MATRIX44>
MATRIX44 getInverseHomogeneousMatrixVal() const

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

virtual void setToNaN() = 0

Set all data fields to quiet NaN.

static bool is3DPoseOrPoint()

Return true for poses or points with a Z component, false otherwise.