Class SpatialVector#

Class Documentation#

class SpatialVector#

Represents a 6D spatial vector, split into angular (w) and linear (v) components.

See Spatial notation section for more discussion on spatial notation.

Public Functions

SpatialVector()#

Construct initialized to zero.

SpatialVector(const Vec6 &sv)#

Construct using a 6 vector. The first 3 components will be put into w and the last 3 components will be put into v.

Parameters:

sv – 6-element vector representing the entire spatial vector.

SpatialVector(const Vec3 &w, const Vec3 &v)#

Construct using two 3-element vectors. The first will become w and the second will become v.

Parameters:
  • w – Angular portion of the spatial vector.

  • v – Linear portion of the spatial vector.

SpatialVector(const SpatialVector &other)#

Copy constructor.

Parameters:

other – The SpatialVector to copy from.

SpatialVector &operator=(const SpatialVector &other)#

Copy assignment operator.

Parameters:

other – The SpatialVector to assign from.

Returns:

Reference to this object.

SpatialVector(SpatialVector &&other) noexcept#

Move constructor.

Parameters:

other – The SpatialVector to move from.

SpatialVector &operator=(SpatialVector &&other) noexcept#

Move assignment operator.

Parameters:

other – The SpatialVector to move from.

Returns:

Reference to this object.

inline std::string typeString() const#

Return object type as a string.

Returns:

String “SpatialVector”.

std::string dumpString(const std::string &prefix = "", unsigned int precision = 10, bool exponential = false) const#

Dump the object as a formatted string.

Parameters:
  • prefix – Optional prefix for each line.

  • precision – Number of digits to use for floating point values.

  • exponential – Use exponential formatting.

Returns:

Formatted string representation.

void dump(const std::string &prefix = "", unsigned int precision = 10, bool exponential = false) const#

Write dumpString to std::cout.

Parameters:
  • prefix – Optional prefix for each line.

  • precision – Number of digits to use for floating point values.

  • exponential – Use exponential formatting.

bool isZero(double prec = MATH_EPSILON) const#

Return true if the spatial vector is zero.

Parameters:

prec – Tolerance to use when comparing with zero.

Returns:

True if both angular and linear components are zero.

void setZero()#

Zero out the spatial vector’s values.

void uninitialize()#

Mark the spatial vector as uninitialized.

bool isInitialized() const#

Check if the spatial vector is initialized.

Returns:

True if both angular and linear components are initialized.

bool operator==(const SpatialVector &other) const#

Equality operator.

Parameters:

other – Another SpatialVector to compare with.

Returns:

True if both components are equal.

double operator*(const SpatialVector &other) const#

Dot product with another spatial vector.

Parameters:

other – The SpatialVector to compute the dot product with.

Returns:

Dot product result.

SpatialVector operator*(double scale) const#

Scalar multiplication.

Parameters:

scale – Scalar value to multiply by.

Returns:

Scaled SpatialVector.

SpatialVector operator+(const SpatialVector &other) const#

Component-wise addition.

Parameters:

other – The SpatialVector to add to this one.

Returns:

Resulting SpatialVector sum.

SpatialVector &operator+=(const SpatialVector &other)#

In-place component-wise addition.

Parameters:

other – The SpatialVector to add to this one in-place.

Returns:

Reference to this object.

SpatialVector operator-() const#

Negation operator.

Returns:

Negated SpatialVector.

SpatialVector operator-(const SpatialVector &other) const#

Subtract another SpatialVector.

Parameters:

other – The SpatialVector to subtract from this one.

Returns:

Resulting SpatialVector.

SpatialVector operator-=(const SpatialVector &other)#

In-place subtraction.

Parameters:

other – The SpatialVector to subtract from this one.

Returns:

Reference to this object.

SpatialVector operator+(const Vec6 &vec) const#

Add a Vec6 to this spatial vector.

Parameters:

vec – The 6D vector to add to this SpatialVector.

Returns:

Resulting SpatialVector.

SpatialVector operator-(const Vec6 &vec) const#

Subtract a Vec6 from this spatial vector.

Parameters:

vec – The 6D vector to subtract from this SpatialVector.

Returns:

Resulting SpatialVector.

bool isApprox(const SpatialVector &other, double prec = MATH_EPSILON) const#

Check if another spatial vector is approximately equal within precision.

Parameters:
  • other – The SpatialVector to compare to this one.

  • prec – Precision tolerance.

Returns:

True if approximately equal.

const Vec3 &getw() const#

Get the angular portion of the spatial vector.

Returns:

Const reference to angular vector.

void setw(const Vec3 &w)#

Set the angular portion of the spatial vector.

Parameters:

w – New angular vector.

const Vec3 &getv() const#

Get the linear portion of the spatial vector.

Returns:

Const reference to linear vector.

void setv(const Vec3 &v)#

Set the linear portion of the spatial vector.

Parameters:

v – New linear vector.

Vec6 toVector6() const#

Convert to a 6-vector by combining the w and v parts as [w;v].

Returns:

Combined 6D vector.

SpatialVector cross(const SpatialVector &other)#

Compute 6-D cross product with another spatial vector.

\[\begin{split} A \times B = \tilde A B = \begin{bmatrix} \tilde A_w & \tilde A_v \\ 0 & \tilde A_w \end{bmatrix} \begin{bmatrix} B_w \\ B_v \end{bmatrix} \end{split}\]

Parameters:

other – The SpatialVector to compute the cross product with.

Returns:

Resulting SpatialVector.

Mat66 tilde() const#

Compute 6-D cross product with another spatial vector.

\[\begin{split} \tilde A = \begin{bmatrix} \tilde A_w & 0 \\ \tilde A_v & \tilde A_w \end{bmatrix} \begin{bmatrix} B_w \\ B_v \end{bmatrix} \end{split}\]

Returns:

Resulting SpatialVector.

SpatialVector barprod(const SpatialVector &other)#

Compute the bar product with another spatial vector.

\[\begin{split} \bar A B = - {\tilde A}^* B = \begin{bmatrix} \tilde A_w & \tilde A_v \\ 0 & \tilde A_w \end{bmatrix} \begin{bmatrix} B_w \\ B_v \end{bmatrix} \end{split}\]

Parameters:

other – The SpatialVector to compute the bar product with.

Returns:

Resulting SpatialVector.

SpatialVector multiplyFromLeft(const Mat66 &mat) const#

Multiply from the vector from left with a matrix, i.e v * mat.

Parameters:

mat – Matrix to multiply.

Returns:

Resulting SpatialVector.