Class sym::Unit3

template<typename ScalarType>
class Unit3

Autogenerated C++ implementation of symforce.geo.unit3.Unit3.

Direction in R^3 represented as a unit vector on the S^2 sphere manifold.

Storage is three dimensional, and tangent space is two dimensional. Due to the nature of the manifold, the unit X vector is handled as a singularity.

The implementation of the retract and local_coordinates functions are based on Appendix B.2 :

[Hertzberg 2013] Integrating Generic Sensor Fusion Algorithms with Sound State Representations through Encapsulation of Manifolds

The retract operation performs a perturbation to the desired unit X vector, which is then rotated to desired position along the actual stored unit vector through a Householder-reflection + relection across the XZ plane.

x.retract(delta) = x [+] delta = Rx * Exp(delta), where
Exp(delta) = [cos(||delta||), sinc(||delta||) * delta], and
Rx = (I - 2 vv^T / (v^Tv))X, v = x - e_x != 0, X is a matrix negating 2nd vector component
   = diag(1, -1, -1)       , x = e_x
See: unit3_visualization.ipynb for a visualization of the Unit3 manifold.

Public Types

using Scalar = ScalarType
using Self = Unit3<Scalar>
using DataVec = Eigen::Matrix<Scalar, 3, 1, Eigen::DontAlign>
using TangentVec = Eigen::Matrix<Scalar, 2, 1>
using SelfJacobian = Eigen::Matrix<Scalar, 2, 2>
using Vector3 = Eigen::Matrix<Scalar, 3, 1>

Public Functions

inline explicit Unit3(const DataVec &data, const bool normalize = true)

Construct from data vec

Parameters:

normalize – Project to the manifold on construction. This ensures numerical stability as this constructor is called after each codegen operation. Constructing from a normalized vector may be faster, e.g. with FromStorage.

inline const DataVec &Data() const
const Eigen::Matrix<Scalar, 3, 2> Basis(const Scalar epsilon) const

Returns a :class:Matrix32 with the basis vectors of the tangent space (in R^3) at the current Unit3 direction.

const Vector3 ToUnitVector() const

Returns a :class:Vector3 version of the unit direction.

inline void ToStorage(Scalar *const vec) const
inline Self Retract(const TangentVec &vec, const Scalar epsilon = kDefaultEpsilon<Scalar>) const
inline TangentVec LocalCoordinates(const Self &b, const Scalar epsilon = kDefaultEpsilon<Scalar>) const
inline Self Interpolate(const Self b, const Scalar alpha, const Scalar epsilon = kDefaultEpsilon<Scalar>) const
inline bool IsApprox(const Self &b, const Scalar tol) const
template<typename ToScalar>
inline Unit3<ToScalar> Cast() const
inline bool operator==(const Unit3 &rhs) const
inline bool operator!=(const Unit3 &rhs) const

Public Static Functions

template<typename Generator>
static inline Unit3 Random(Generator &gen, Scalar epsilon = kDefaultEpsilon<Scalar>)
static inline const sym::Unit3<Scalar> FromVector(const Vector3 &a)

Return a :class:Unit3 that points along the direction of vector a

a will be normalized.

static inline const sym::Unit3<Scalar> FromUnitVector(const Vector3 &a)

Return a :class:Unit3 that points along the direction of vector a

a is expected to be a unit vector.

static const sym::Unit3<Scalar> RandomFromUniformSamples(const Scalar u1, const Scalar u2, const Scalar epsilon)

Generate a random :class:Unit3 direction from two variables uniformly sampled in [0, 1].

static inline constexpr int32_t StorageDim()
static inline Unit3 FromStorage(const Scalar *const vec)
static inline constexpr int32_t TangentDim()