Template Struct TPoint3D_

Inheritance Relationships

Base Types

Struct Documentation

template<typename T>
struct TPoint3D_ : public mrpt::math::TPoseOrPoint, public mrpt::math::TPoint3D_data<T>, public mrpt::math::internal::ProvideStaticResize<TPoint3D_<T>>

Base template for TPoint3D (double) and TPoint3Df (float).

Represents a point (or free vector) in the 3D Euclidean space R^3. Coordinates are stored as (x, y, z) in a 1-byte-packed struct (no padding).

This is a lightweight POD-like type intended for storage, arithmetic, and interoperability with NumPy / Eigen arrays. It supports:

  • Standard vector arithmetic (+, -, scalar *, /).

  • Dot product (dot()) and cross product (cross()).

  • Euclidean norm and distance queries.

  • std::tuple structured-binding (auto [x,y,z] = pt;).

When applying SE(3) rigid-body transformations, use mrpt::poses::CPose3D::composePoint() or mrpt::math::TPose3D::composePoint() rather than adding translation manually.

Note

TVector3D is a type alias for TPoint3D (same storage; use that name when the object is a free vector, e.g. a linear velocity or surface normal).

Public Functions

inline constexpr TPoint3D_()

Default constructor. Initializes to zeros.

inline constexpr TPoint3D_(T xx, T yy, T zz)

Constructor from coordinates.

template<typename U>
inline TPoint3D_(const TPoint3D_data<U> &p)

Constructor from coordinates.

template<typename U>
inline explicit TPoint3D_(const mrpt::math::CMatrixFixed<U, 3, 1> &m)

Constructor from column vector.

explicit TPoint3D_(const TPoint2D_<T> &p)

Constructor from TPoint2D; the z coordinate is set to zero.

See also

TPoint2D

explicit TPoint3D_(const TPose2D &p)

Constructor from TPose2D; retains (x,y) from the translational part and sets z=0; the heading angle phi is discarded.

See also

TPose2D

explicit TPoint3D_(const TPose3D &p)

Constructor from TPose3D; retains only the translational part (x,y,z); all angular coordinates (yaw, pitch, roll) are discarded.

See also

TPose3D

template<typename U>
inline TPoint3D_<U> cast() const

Return a copy of this object using type U for coordinates

inline T &operator[](size_t i)

Coordinate access using operator[]. Order: x,y,z

inline constexpr T operator[](size_t i) const

Coordinate access using operator[]. Order: x,y,z

template<size_t I>
inline const T &get() const

Method so std::tuple, std::tie() works with TPoint3D

inline constexpr auto as_tuple() const
inline T distanceTo(const TPoint3D_<T> &p) const

Point-to-point distance.

inline T sqrDistanceTo(const TPoint3D_<T> &p) const

Point-to-point distance, squared.

inline T sqrNorm() const

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

inline T norm() const

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

inline TPoint3D_<T> unitarize() const

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

inline TPoint3D_<T> &operator*=(const T f)

Scale point/vector

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

Gets the pose as a vector of doubles.

Template Parameters:

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

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

inline TPoint3D_<T> &operator+=(const TPoint3D_<T> &p)

Translation.

inline TPoint3D_<T> &operator-=(const TPoint3D_<T> &p)

Difference between points.

inline constexpr TPoint3D_<T> operator+(const TPoint3D_<T> &p) const

Points addition.

inline constexpr TPoint3D_<T> operator-(const TPoint3D_<T> &p) const

Points substraction.

inline constexpr T dot(const TPoint3D_<T> &p) const

Scalar product s=dot(this,p)

inline constexpr TPoint3D_<T> cross(const TPoint3D_<T> &p) const

Cross product res = cross(this, p)

inline constexpr TPoint3D_<T> operator*(T d) const
inline constexpr TPoint3D_<T> operator/(T d) const
bool operator<(const TPoint3D_<T> &p) const
inline void asString(std::string &s) const

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

See also

fromString

inline std::string asString() const
void fromString(const std::string &s)

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

See also

asString

Throws:

std::exception – On invalid format

Public Static Functions

template<typename Vector>
static inline TPoint3D_<T> FromVector(const Vector &v)

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

Template Parameters:

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

static inline TPoint3D_<T> FromString(const std::string &s)

Public Static Attributes

static constexpr std::size_t static_size = 3