Skip to content

Class inertialsim::geometry::VectorBase

template <typename Derived>

ClassList > inertialsim > geometry > VectorBase

CRTP base for 3-dimensional vector types. More...

  • #include <vector_base.h>

Inherits the following classes: inertialsim::geometry::MatrixLieGroup

Public Types

Type Name
typedef MatrixLieGroup< Derived, 4, 3 > Base

Public Types inherited from inertialsim::geometry::MatrixLieGroup

See inertialsim::geometry::MatrixLieGroup

Type Name
typedef Eigen::Matrix< Scalar, AlgebraDimension, Eigen::Dynamic > AlgebraArray
Matrix of algebra elements (rows = axes, cols = samples).
typedef Eigen::Matrix< Scalar, AlgebraDimension, 1 > AlgebraElement
Algebra element type (vector).
typedef std::vector< GroupElement > GroupArray
Array of group elements.
typedef Eigen::Matrix< Scalar, GroupDimension, GroupDimension > GroupElement
Group element type (square matrix).
typedef Eigen::Matrix< Scalar, AlgebraDimension, AlgebraDimension > JacobianMatrix
Jacobian matrix (algebra to algebra).
typedef std::vector< JacobianMatrix > JacobianMatrixArray
Array of Jacobian matrices.

Public Functions

Type Name
Array3D AsSpherical () const
Return spherical coordinates (radius, polar, azimuth).
Vector3D AsXyz () const
Return Cartesian coordinates.
Vector3D Error (const Derived & reference) const
Calculate error compared to a reference vector.
Vector3D Error (const Vector3D & reference) const
Calculate error compared to a reference array.
int num_vectors () const
Number of vectors stored.
Derived operator* (double scalar) const
Multiply by a scalar.
Derived operator+ (const Derived & rhs) const
Add two vectors.
Derived operator- (const Derived & rhs) const
Subtract two vectors.
Derived operator/ (double scalar) const
Divide by a scalar.

Public Functions inherited from inertialsim::geometry::MatrixLieGroup

See inertialsim::geometry::MatrixLieGroup

Type Name
Vector3D Apply (const Vector3D & vectors) const
Apply the group action to an array of vectors.
Derived Interpolate (const Timestamps & interp_time, Interpolator method=Interpolator::LINEAR) const
Interpolate at given times.
Derived Inverse () const
Invert an instance.
Derived Slice (int start, int end) const
Get a slice of elements.
AlgebraArray TimeDerivative (int order=1, int accuracy=4, const std::string & side="right") const
Compute time derivative using finite differences.
int num_elements () const
Number of elements stored in the instance.
Derived operator* (const Derived & rhs) const
Composition operator on the matrix group. Supports broadcasting: if either lhs or rhs has size 1, it will be broadcast against all elements of the other operand. Derived classes may implement more efficient methods.
Derived operator[] (int index) const
Get a single element by index.
const std::optional< Timestamps > & time () const
Time array (or nullopt if not set).
virtual ~MatrixLieGroup () = default

Public Static Functions

Type Name
Derived FromSpherical (const Array3D & rpa, const std::optional< Timestamps > & time=std::nullopt)
Construct from spherical coordinates (radius, polar, azimuth).
Derived FromXyz (const Vector3D & xyz, const std::optional< Timestamps > & time=std::nullopt)
Construct from Cartesian coordinates.

Public Static Functions inherited from inertialsim::geometry::MatrixLieGroup

See inertialsim::geometry::MatrixLieGroup

Type Name
Derived Compose (const std::vector< Derived > & instances)
Compose a sequence of instances (first to last).
Derived FromIdentity (int num_elements=1)
Create identity elements.
Derived FromRandom (int num_elements=1, std::optional< Eigen::numext::uint64_t > seed=std::nullopt)
Create random elements.

Protected Functions

Type Name
Vector3D ApplyImpl (const Vector3D & rhs) const
Apply (add) vector to input vectors.
AlgebraArray AsAlgebraImpl () const
Return as algebra elements.
GroupArray AsGroupImpl () const
Return as group elements (for CRTP interface).
Derived InverseImpl () const
Return the inverse (negative) of the vector.
VectorBase ()
Default constructor.
VectorBase (const Vector3D & xyz, const std::optional< Timestamps > & time=std::nullopt)
Construct from Cartesian coordinates.
int num_elements_impl () const
Number of vectors stored.

Protected Functions inherited from inertialsim::geometry::MatrixLieGroup

See inertialsim::geometry::MatrixLieGroup

Type Name
AlgebraArray AsAlgebra () const
Get the algebra elements.
GroupArray AsGroup () const
Get the group elements.
Derived CubicHermiteInterpolate (const Timestamps & time) const
Cubic Hermite spline interpolation.
Derived LinearInterpolate (const Timestamps & time) const
Linear interpolation implementation.
MatrixLieGroup (const std::optional< Timestamps > & time=std::nullopt)
Constructor.
Derived & derived ()
CRTP helper to access derived class.
const Derived & derived () const
int num_times () const

Protected Static Functions

Type Name
GroupElement ExpImpl (const AlgebraElement & vector)
Exponential map: vector to homogeneous transform matrix.
Derived FromAlgebraImpl (const AlgebraArray & elements, const std::optional< Timestamps > & time=std::nullopt)
Construct from algebra elements.
Derived FromGroupImpl (const GroupArray & elements, const std::optional< Timestamps > & time)
Construct from group elements (for CRTP interface).
Derived FromIdentityImpl (int num_elements)
Construct identity (zero) vectors.
Derived FromRandomImpl (int num_elements, std::optional< uint64_t > seed=std::nullopt)
Construct random vectors.
JacobianMatrixArray JacobianImpl (const AlgebraArray & vectors, const std::string &="left", bool=false)
Left/Right Jacobian of the vector group.
AlgebraElement LogImpl (const GroupElement & element)
Logarithm map: homogeneous transform to vector.

Protected Static Functions inherited from inertialsim::geometry::MatrixLieGroup

See inertialsim::geometry::MatrixLieGroup

Type Name
GroupElement Exp (const AlgebraElement & vector)
Exponential map from algebra to group.
Derived FromAlgebra (const AlgebraArray & elements, const std::optional< Timestamps > & time)
Create instance from algebra elements.
Derived FromGroup (const GroupArray & elements, const std::optional< Timestamps > & time)
Create instance from group elements.
JacobianMatrixArray Jacobian (const AlgebraArray & algebra, const std::string & side="left", bool inverse=false)
Calculate the Jacobian given algebra elements.
AlgebraElement Log (const GroupElement & element)
Logarithm map from group to algebra.

Detailed Description

Template parameters:

Public Types Documentation

typedef Base

using inertialsim::geometry::VectorBase< Derived >::Base =  MatrixLieGroup<Derived, 4, 3>;

Public Functions Documentation

function AsSpherical

Return spherical coordinates (radius, polar, azimuth).

inline Array3D inertialsim::geometry::VectorBase::AsSpherical () const

Returns:

Spherical coordinates (3xN matrix).


function AsXyz

Return Cartesian coordinates.

inline Vector3D inertialsim::geometry::VectorBase::AsXyz () const

Returns:

Cartesian coordinates (3xN matrix).


function Error [½]

Calculate error compared to a reference vector.

inline Vector3D inertialsim::geometry::VectorBase::Error (
    const Derived & reference
) const

Parameters:

  • reference Reference vector.

Returns:

Error values.


function Error [2/2]

Calculate error compared to a reference array.

inline Vector3D inertialsim::geometry::VectorBase::Error (
    const Vector3D & reference
) const

Parameters:

  • reference Reference coordinates (3xN matrix).

Returns:

Error values.


function num_vectors

Number of vectors stored.

inline int inertialsim::geometry::VectorBase::num_vectors () const


function operator*

Multiply by a scalar.

inline Derived inertialsim::geometry::VectorBase::operator* (
    double scalar
) const

Parameters:

  • scalar Scalar multiplier.

Returns:

New vector containing the product.


function operator+

Add two vectors.

inline Derived inertialsim::geometry::VectorBase::operator+ (
    const Derived & rhs
) const

Parameters:

  • rhs Right-hand side vector.

Returns:

New vector containing the sum.


function operator-

Subtract two vectors.

inline Derived inertialsim::geometry::VectorBase::operator- (
    const Derived & rhs
) const

Parameters:

  • rhs Right-hand side vector.

Returns:

New vector containing the difference.


function operator/

Divide by a scalar.

inline Derived inertialsim::geometry::VectorBase::operator/ (
    double scalar
) const

Parameters:

  • scalar Scalar divisor.

Returns:

New vector containing the quotient.


Public Static Functions Documentation

function FromSpherical

Construct from spherical coordinates (radius, polar, azimuth).

static inline Derived inertialsim::geometry::VectorBase::FromSpherical (
    const Array3D & rpa,
    const std::optional< Timestamps > & time=std::nullopt
) 

Parameters:

  • rpa Spherical coordinates (3xN matrix).
  • time Optional time array.

Returns:

Derived instance.


function FromXyz

Construct from Cartesian coordinates.

static inline Derived inertialsim::geometry::VectorBase::FromXyz (
    const Vector3D & xyz,
    const std::optional< Timestamps > & time=std::nullopt
) 

Parameters:

  • xyz Cartesian coordinates (3xN matrix).
  • time Optional time array.

Returns:

Derived instance.


Protected Functions Documentation

function ApplyImpl

Apply (add) vector to input vectors.

inline Vector3D inertialsim::geometry::VectorBase::ApplyImpl (
    const Vector3D & rhs
) const

Parameters:

  • rhs Input vectors (3xN matrix).

Returns:

Sum of vectors.


function AsAlgebraImpl

Return as algebra elements.

inline AlgebraArray inertialsim::geometry::VectorBase::AsAlgebraImpl () const

Returns:

Algebra elements (3xN matrix).


function AsGroupImpl

Return as group elements (for CRTP interface).

inline GroupArray inertialsim::geometry::VectorBase::AsGroupImpl () const

Returns:

Array of 4x4 homogeneous transform matrices.


function InverseImpl

Return the inverse (negative) of the vector.

inline Derived inertialsim::geometry::VectorBase::InverseImpl () const

Returns:

Vector with negated coordinates.


function VectorBase [½]

Default constructor.

inline inertialsim::geometry::VectorBase::VectorBase () 


function VectorBase [2/2]

Construct from Cartesian coordinates.

inline explicit inertialsim::geometry::VectorBase::VectorBase (
    const Vector3D & xyz,
    const std::optional< Timestamps > & time=std::nullopt
) 

Parameters:

  • xyz Cartesian coordinates (3xN matrix).
  • time Optional time array.

function num_elements_impl

Number of vectors stored.

inline int inertialsim::geometry::VectorBase::num_elements_impl () const


Protected Static Functions Documentation

function ExpImpl

Exponential map: vector to homogeneous transform matrix.

static inline GroupElement inertialsim::geometry::VectorBase::ExpImpl (
    const AlgebraElement & vector
) 

Parameters:

  • vector 3D vector (algebra element).

Returns:

4x4 homogeneous transform matrix (group element).


function FromAlgebraImpl

Construct from algebra elements.

static inline Derived inertialsim::geometry::VectorBase::FromAlgebraImpl (
    const AlgebraArray & elements,
    const std::optional< Timestamps > & time=std::nullopt
) 

Parameters:

  • elements Algebra elements (3xN matrix of vectors).
  • time Optional time array.

Returns:

Derived instance.


function FromGroupImpl

Construct from group elements (for CRTP interface).

static inline Derived inertialsim::geometry::VectorBase::FromGroupImpl (
    const GroupArray & elements,
    const std::optional< Timestamps > & time
) 

Parameters:

  • elements Array of 4x4 homogeneous transform matrices.
  • time Optional time array.

Returns:

Derived instance.


function FromIdentityImpl

Construct identity (zero) vectors.

static inline Derived inertialsim::geometry::VectorBase::FromIdentityImpl (
    int num_elements
) 

Parameters:

  • num_elements Number of zero vectors.

Returns:

Derived instance.


function FromRandomImpl

Construct random vectors.

static inline Derived inertialsim::geometry::VectorBase::FromRandomImpl (
    int num_elements,
    std::optional< uint64_t > seed=std::nullopt
) 

Parameters:

  • num_elements Number of random vectors.
  • seed Optional random seed.

Returns:

Derived instance with random coordinates.


function JacobianImpl

Left/Right Jacobian of the vector group.

static inline JacobianMatrixArray inertialsim::geometry::VectorBase::JacobianImpl (
    const AlgebraArray & vectors,
    const std::string &="left",
    bool=false
) 

For vectors, both left and right Jacobians are identity.

Parameters:

  • vectors Vectors (3xN matrix).
  • inverse If true, return inverse Jacobian (also identity).

Returns:

Vector of 3x3 identity matrices.


function LogImpl

Logarithm map: homogeneous transform to vector.

static inline AlgebraElement inertialsim::geometry::VectorBase::LogImpl (
    const GroupElement & element
) 

Parameters:

  • element 4x4 homogeneous transform matrix (group element).

Returns:

3D vector (algebra element).


Friends Documentation

friend operator*

Scalar multiplication from the left (friend declaration).

inline Derived inertialsim::geometry::VectorBase::operator* (
    double scalar,
    const Derived & vec
) 

Parameters:

  • scalar Scalar multiplier.
  • vec Vector to multiply.

Returns:

New vector containing the product.



The documentation for this class was generated from the following file cpp/include/inertialsim/geometry/vector_base.h