gtsam
Loading...
Searching...
No Matches
gtsam::Unit3 Class Reference

Detailed Description

Represents a 3D point on a unit sphere.

Manifold

enum  CoordinatesMode { EXPMAP , RENORM }
size_t dim () const
 Dimensionality of tangent space = 2 DOF.
Unit3 retract (const Vector2 &v, OptionalJacobian< 2, 2 > H={}) const
 The retract function.
Vector2 localCoordinates (const Unit3 &s) const
 The local coordinates function.
Vector2 localCoordinates (const Unit3 &s, OptionalJacobian< 2, 2 > H1, OptionalJacobian< 2, 2 > H2={}) const
 Local coordinates with derivatives in the tangent bases of this and s.
static size_t Dim ()
 Dimensionality of tangent space = 2 DOF.

Constructors

 Unit3 ()
 Default constructor.
 Unit3 (const Vector3 &p)
 Construct from point.
 Unit3 (double x, double y, double z)
 Construct from x,y,z.
 Unit3 (const Point2 &p, double f)
 Construct from 2D point in plane at focal length f Unit3(p,1) can be viewed as normalized homogeneous coordinates of 2D point.
 Unit3 (const Unit3 &u)
 Copy constructor: copies essential data and discards caches.
Unit3 & operator= (const Unit3 &u)
 Copy assignment: copies essential data and invalidates local caches.
static Unit3 FromPoint3 (const Point3 &point, OptionalJacobian< 2, 3 > H={})
 Named constructor from Point3 with optional Jacobian.
static Unit3 Random (std::mt19937 &rng)
 Random direction, using boost::uniform_on_sphere Example: std::mt19937 engine(42); Unit3 unit = Unit3::Random(engine);.

Testable

void print (const std::string &s=std::string()) const
 The print fuction.
bool equals (const Unit3 &s, double tol=1e-9) const
 The equals function with tolerance.
GTSAM_EXPORT friend std::ostream & operator<< (std::ostream &os, const Unit3 &pair)

Other functionality

const Matrix32 & basis (OptionalJacobian< 6, 2 > H={}) const
 Returns the local coordinate frame to tangent plane It is a 3*2 matrix [b1 b2] composed of two orthogonal directions tangent to the sphere at the current direction.
Matrix3 skew () const
 Return skew-symmetric associated with 3D point on unit sphere.
Point3 point3 (OptionalJacobian< 3, 2 > H={}) const
 Return unit-norm Point3.
Vector3 unitVector (OptionalJacobian< 3, 2 > H={}) const
 Return unit-norm Vector.
Vector3 scaled (double magnitude, OptionalJacobian< 3, 2 > H_this={}, OptionalJacobian< 3, 1 > H_magnitude={}) const
 Return this direction scaled by a magnitude, i.e.
double dot (const Unit3 &q, OptionalJacobian< 1, 2 > H1={}, OptionalJacobian< 1, 2 > H2={}) const
 Return dot product with q.
Vector2 errorVector (const Unit3 &q, OptionalJacobian< 2, 2 > H_p={}, OptionalJacobian< 2, 2 > H_q={}) const
 Signed, vector-valued error between two directions NOTE(hayk): This method has zero derivatives if this (p) and q are orthogonal.
double distance (const Unit3 &q, OptionalJacobian< 1, 2 > H={}) const
 Distance between two directions.
Unit3 cross (const Unit3 &q, OptionalJacobian< 2, 2 > H_p={}, OptionalJacobian< 2, 2 > H_q={}) const
 Cross-product between two Unit3s.
Point3 cross (const Point3 &q, OptionalJacobian< 3, 2 > H_p={}, OptionalJacobian< 3, 3 > H_q={}) const
 Cross-product w Point3.
Point3 operator* (double s, const Unit3 &d)
 Return scaled direction as Point3 (no Jacobians; see scaled()).

Static Public Attributes

static constexpr auto dimension = 2

Member Enumeration Documentation

◆ CoordinatesMode

Enumerator
EXPMAP 

Use the exponential map to retract.

RENORM 

Retract with vector addition and renormalize.

Member Function Documentation

◆ basis()

const Matrix32 & gtsam::Unit3::basis ( OptionalJacobian< 6, 2 > H = {}) const

Returns the local coordinate frame to tangent plane It is a 3*2 matrix [b1 b2] composed of two orthogonal directions tangent to the sphere at the current direction.

Provides derivatives of the basis with the two basis vectors stacked up as a 6x1.

◆ localCoordinates()

Vector2 gtsam::Unit3::localCoordinates ( const Unit3 & s,
OptionalJacobian< 2, 2 > H1,
OptionalJacobian< 2, 2 > H2 = {} ) const

Local coordinates with derivatives in the tangent bases of this and s.

Derivatives are undefined at the antipode; requesting them there throws std::domain_error. The value-only overload retains its antipodal convention.

◆ scaled()

Vector3 gtsam::Unit3::scaled ( double magnitude,
OptionalJacobian< 3, 2 > H_this = {},
OptionalJacobian< 3, 1 > H_magnitude = {} ) const

Return this direction scaled by a magnitude, i.e.

magnitude * unitVector(). Useful to reconstruct a physical vector from a direction and a known (or separately estimated) magnitude, e.g. a gravity or magnetic field vector.

Parameters
magnitudescale applied to the unit vector
H_thisoptional 3x2 Jacobian wrt this direction
H_magnitudeoptional 3x1 Jacobian wrt the magnitude
See also
operator*(double, const Unit3&), which returns the same value without Jacobians

The documentation for this class was generated from the following files:
  • /tmp/gtsam-4.3.0-doxygen.rsXPUS/source/gtsam/geometry/Unit3.h
  • /tmp/gtsam-4.3.0-doxygen.rsXPUS/source/gtsam/geometry/Unit3.cpp