struct mrpt::math::TTwist3D

Overview

3D twist: 3D velocity vector (vx,vy,vz) + angular velocity (wx,wy,wz)

See also:

mrpt::math::TTwist2D, mrpt::math::TPose3D

#include <mrpt/math/TTwist3D.h>

struct TTwist3D: public mrpt::math::internal::ProvideStaticResize
{
    // enums

    enum
    {
        static_size = 6,
    };

    // fields

    double vx {.0};
    double vy {.0};
    double vz {.0};
    double wx {.0};
    double wy {.0};
    double wz {.0};

    // construction

    TTwist3D(double vx_, double vy_, double vz_, double wx_, double wy_, double wz_);
    TTwist3D();

    // methods

    double& operator [] (size_t i);
    constexpr double operator [] (size_t i) const;
    double& operator () (int row, int col);
    constexpr double operator () (int row, int col) const;
    void operator *= (const double k);

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

    template <typename Vector>
    Vector asVector() const;

    template <typename VECTORLIKE>
    void fromVector(const VECTORLIKE& v);

    bool operator == (const TTwist3D& o) const;
    bool operator != (const TTwist3D& o) const;
    void asString(std::string& s) const;
    std::string asString() const;
    void rotate(const mrpt::math::TPose3D& rot);
    TTwist3D rotated(const mrpt::math::TPose3D& rot) const;
    void fromString(const std::string& s);
    constexpr std::size_t rows() const;
    constexpr std::size_t cols() const;
    constexpr std::size_t size() const;

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

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

Inherited Members

public:
    // methods

    void resize(std::size_t n);

Fields

double vx {.0}

Velocity components: X,Y (m/s)

double wx {.0}

Angular velocity (rad/s)

Construction

TTwist3D(double vx_, double vy_, double vz_, double wx_, double wy_, double wz_)

Constructor from components.

TTwist3D()

Default fast constructor.

Initializes to zeros

Methods

double& operator [] (size_t i)

Coordinate access using operator[].

Order: vx,vy,vz, wx, wy, wz

constexpr double operator [] (size_t i) const

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

double& operator () (int row, int col)

(i,0) access operator (provided for API compatibility with matrices).

See also:

operator[]

constexpr double operator () (int row, int col) const

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

void operator *= (const double k)

Scale factor.

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

Transformation into vector [vx vy vz wx wy wz].

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.

template <typename VECTORLIKE>
void fromVector(const VECTORLIKE& v)

Sets from a vector [vx vy vz wx wy wz].

void asString(std::string& s) const

Returns a human-readable textual representation of the object (eg: “[vx vy vz wx wy wz]”, omegas in deg/s)

See also:

fromString

void rotate(const mrpt::math::TPose3D& rot)

Transform all 6 components for a change of reference frame from “A” to another frame “B” whose rotation with respect to “A” is given by rot.

The translational part of the pose is ignored

TTwist3D rotated(const mrpt::math::TPose3D& rot) const

Like rotate(), but returning a copy of the rotated twist.

New in MRPT 2.3.2

void fromString(const std::string& s)

Set the current object value from a string generated by ‘asString’ (eg: “[vx vy vz wx wy wz]” )

Parameters:

std::exception

On invalid format

See also:

asString

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

Builds from the first 6 elements of a vector-like object: [vx vy vz wx wy wz].

Parameters:

Vector

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