template struct mrpt::math::TPoint3D_
Overview
Base template for TPoint3D and TPoint3Df.
[1-byte memory packed, no padding]
#include <mrpt/math/TPoint3D.h> template <typename T> struct TPoint3D_: public mrpt::math::TPoseOrPoint, public mrpt::math::TPoint3D_data, public mrpt::math::internal::ProvideStaticResize { // enums enum { static_size = 3, }; // fields T x; // construction TPoint3D_(); TPoint3D_(T xx, T yy, T zz); template <typename U> TPoint3D_(const TPoint3D_data<U>& p); template <typename U> TPoint3D_(const mrpt::math::CMatrixFixed<U, 3, 1>& m); TPoint3D_(const TPoint2D_<T>& p); TPoint3D_(const TPose2D& p); TPoint3D_(const TPose3D& p); // methods template <typename U> TPoint3D_<U> cast() const; T& operator [] (size_t i); constexpr T operator [] (size_t i) const; T distanceTo(const TPoint3D_<T>& p) const; T sqrDistanceTo(const TPoint3D_<T>& p) const; T sqrNorm() const; T norm() const; TPoint3D_<T> unitarize() const; TPoint3D_<T>& operator *= (const T f); template <typename Vector> void asVector(Vector& v) const; template <typename Vector> Vector asVector() const; TPoint3D_<T>& operator += (const TPoint3D_<T>& p); TPoint3D_<T>& operator -= (const TPoint3D_<T>& p); constexpr TPoint3D_<T> operator + (const TPoint3D_<T>& p) const; constexpr TPoint3D_<T> operator - (const TPoint3D_<T>& p) const; constexpr TPoint3D_<T> operator * (T d) const; constexpr TPoint3D_<T> operator/ (T d) const; bool operator < (const TPoint3D_<T>& p) const; void asString(std::string& s) const; std::string asString() const; void fromString(const std::string& s); template <typename Vector> static TPoint3D FromVector(const Vector& v); static TPoint3D_<T> FromString(const std::string& s); };
Inherited Members
public: // fields T y; T z; // methods void resize(std::size_t n);
Fields
T x
X,Y,Z coordinates.
Construction
TPoint3D_()
Default constructor.
Initializes to zeros.
TPoint3D_(T xx, T yy, T zz)
Constructor from coordinates.
template <typename U> TPoint3D_(const TPoint3D_data<U>& p)
Constructor from coordinates.
template <typename U> TPoint3D_(const mrpt::math::CMatrixFixed<U, 3, 1>& m)
Constructor from column vector.
TPoint3D_(const TPoint2D_<T>& p)
Implicit constructor from TPoint2D.
Zeroes the z.
See also:
TPoint3D_(const TPose2D& p)
Constructor from TPose2D, losing information.
Zeroes the z.
See also:
TPoint3D_(const TPose3D& p)
Constructor from TPose3D, losing information.
See also:
Methods
template <typename U> TPoint3D_<U> cast() const
Return a copy of this object using type U for coordinates.
T& operator [] (size_t i)
Coordinate access using operator[].
Order: x,y,z
constexpr T operator [] (size_t i) const
Coordinate access using operator[].
Order: x,y,z
T distanceTo(const TPoint3D_<T>& p) const
Point-to-point distance.
T sqrDistanceTo(const TPoint3D_<T>& p) const
Point-to-point distance, squared.
T sqrNorm() const
Squared norm: |v|^2 = x^2+y^2+z^2
T norm() const
Point norm: |v| = sqrt(x^2+y^2+z^2)
TPoint3D_<T> unitarize() const
Returns this vector with unit length: v/norm(v)
TPoint3D_<T>& operator *= (const T f)
Scale point/vector.
template <typename Vector> void asVector(Vector& v) const
Gets the pose as a vector of doubles.
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.
TPoint3D_<T>& operator += (const TPoint3D_<T>& p)
Translation.
TPoint3D_<T>& operator -= (const TPoint3D_<T>& p)
Difference between points.
constexpr TPoint3D_<T> operator + (const TPoint3D_<T>& p) const
Points addition.
constexpr TPoint3D_<T> operator - (const TPoint3D_<T>& p) const
Points substraction.
void asString(std::string& s) const
Returns a human-readable textual representation of the object (eg: “[0.02 1.04 -0.8]” )
See also:
void fromString(const std::string& s)
Set the current object value from a string generated by ‘asString’ (eg: “[0.02 1.04 -0.8]” )
Parameters:
std::exception |
On invalid format |
See also:
template <typename Vector> static TPoint3D FromVector(const Vector& v)
Builds from the first 3 elements of a vector-like object: [x y z].
Parameters:
Vector |
It can be std::vector<double>, Eigen::VectorXd, etc. |