1#ifndef SRC_COMMON_SPATIAL_ATTITUDE_UTILS_HPP_
2#define SRC_COMMON_SPATIAL_ATTITUDE_UTILS_HPP_
6#include "common/decimal.hpp"
274decimal Distance(
const Vec2 &,
const Vec2 &);
284decimal Distance(
const Vec3 &,
const Vec3 &);
294decimal Angle(
const Vec3 &,
const Vec3 &);
306decimal AngleUnit(
const Vec3 &,
const Vec3 &);
331 decimal
At(
int i,
int j)
const;
356 decimal
Trace()
const;
427extern const Mat3 kIdentityMat3;
453 decimal
de = DECIMAL(0.0),
454 decimal
roll = DECIMAL(0.0))
561 decimal
Angle()
const;
580 bool IsUnit(decimal tolerance)
const;
750Quaternion SphericalToQuaternion(decimal ra, decimal dec, decimal roll);
764 {
return SphericalToQuaternion(angles.
ra, angles.
de, angles.
roll); }
779Vec3 SphericalToSpatial(decimal ra, decimal de);
792void SpatialToSpherical(
const Vec3 &, decimal &ra, decimal &de);
805constexpr decimal RadToDeg(decimal rad) {
806 return rad*DECIMAL(180.0)/DECIMAL_M_PI;
816constexpr decimal DegToRad(decimal deg) {
817 return deg/DECIMAL(180.0)*DECIMAL_M_PI;
832constexpr decimal RadToArcSec(decimal rad) {
833 return RadToDeg(rad) * DECIMAL(3600.0);
844constexpr decimal ArcSecToRad(decimal arcSec) {
845 return DegToRad(arcSec / DECIMAL(3600.0));
An Attitude is an immutable object that represents the orientation of a 3D point.
Definition attitude-utils.hpp:627
Attitude()=default
Constructs this by default.
Attitude(const Quaternion &quat)
Constructs an Attitude object from Quaternion information.
Definition attitude-utils.hpp:639
Quaternion GetQuaternion() const
Provides the Quaternion corresponding to this Attitude.
Definition attitude-utils.cpp:336
EulerAngles ToSpherical() const
Obtains the Euler Angles of this Attitude.
Definition attitude-utils.cpp:358
Attitude(const Mat3 &matrix)
Constructs an Attitude object from a Direction Cosine Matrix (A matrix holding the direction cosines ...
Definition attitude-utils.hpp:647
Quaternion quaternion
Internal Quaternion Representation.
Definition attitude-utils.hpp:696
Mat3 dcm
Internal DCM Representation.
Definition attitude-utils.hpp:698
AttitudeType
Represents what internal representation for attitude is being used.
Definition attitude-utils.hpp:686
@ NullType
No Internal representation.
Definition attitude-utils.hpp:688
@ DCMType
DCM Internal Representation.
Definition attitude-utils.hpp:692
@ QuaternionType
Quaternion Internal Representation.
Definition attitude-utils.hpp:690
AttitudeType type
Internal Representation Type.
Definition attitude-utils.hpp:700
Vec3 Rotate(const Vec3 &) const
Obtains a vector rotated to this Attitude from another vector (Convert a vector from the reference fr...
Definition attitude-utils.cpp:369
Mat3 GetDCM() const
Obtains the rotation matrix from this Attitude.
Definition attitude-utils.cpp:347
An EulerAngle is a mutable Object representing Euler Angles of a 3D point.
Definition attitude-utils.hpp:443
decimal ra
Right ascension. How far we yaw left. Yaw is performed first.
Definition attitude-utils.hpp:458
decimal de
Declination. How far we pitch up (or down if negative). Pitch is performed second,...
Definition attitude-utils.hpp:460
decimal roll
How far we roll counterclockwise. Roll is performed last (after yaw and pitch).
Definition attitude-utils.hpp:462
constexpr EulerAngles(decimal ra=DECIMAL(0.0), decimal de=DECIMAL(0.0), decimal roll=DECIMAL(0.0))
Initializes an EulerAngles with corresponding parameters.
Definition attitude-utils.hpp:452
A Mat3 is a mutable object that represents a 3x3 Matrix.
Definition attitude-utils.hpp:316
decimal Det() const
Obtains the determinant of this Matrix.
Definition attitude-utils.cpp:168
decimal Trace() const
Obtains the trace of this Matrix.
Definition attitude-utils.cpp:164
Mat3 operator+(const Mat3 &) const
Matrix Addition (element-wise)
Definition attitude-utils.cpp:174
decimal At(int i, int j) const
Obtains an entry in this Matrix.
Definition attitude-utils.cpp:152
Vec3 Row(int) const
Obtains one of the row vectors in this Matrix.
Definition attitude-utils.cpp:160
Mat3 Transpose() const
Obtains the transpose of this Matrix.
Definition attitude-utils.cpp:208
decimal x[9]
The matrix entries.
Definition attitude-utils.hpp:319
Mat3 Inverse() const
Obtains the inverse of this Matrix.
Definition attitude-utils.cpp:216
Vec3 Column(int) const
Obtains one of the column vectors in this Matrix.
Definition attitude-utils.cpp:156
Mat3 operator*(const Mat3 &) const
Matrix Multiplication.
Definition attitude-utils.cpp:182
A Quaternion is a mutable object that represents a Quaternion.
Definition attitude-utils.hpp:474
Quaternion(decimal real, decimal i, decimal j, decimal k)
Creates a Quaternion with components.
Definition attitude-utils.hpp:503
decimal Angle() const
Provides the amount of rotations represented by this Quaterion.
Definition attitude-utils.cpp:288
Vec3 Vector() const
The axis of the represented rotation.
Definition attitude-utils.cpp:273
Vec3 Rotate(const Vec3 &) const
Rotates a vector about this Quaternion.
Definition attitude-utils.cpp:283
bool IsUnit(decimal tolerance) const
Tells client if this Quarternion is a unit quaternion.
Definition attitude-utils.cpp:301
decimal j
The j component.
Definition attitude-utils.hpp:605
decimal real
The real component.
Definition attitude-utils.hpp:601
Quaternion Conjugate() const
Effectively computes a quaternion representing the inverse rotation of the original.
Definition attitude-utils.cpp:269
Quaternion Canonicalize() const
Provides the canonicalized Quaternion of this, if it is not already canonicalized.
Definition attitude-utils.cpp:305
decimal i
The i component.
Definition attitude-utils.hpp:603
void SetAngle(decimal)
Changes the rotation represented in this quarterion.
Definition attitude-utils.cpp:296
Quaternion operator*(const Quaternion &other) const
Multiply two quaternions using the usual definition of quaternion multiplication (effectively compose...
Definition attitude-utils.cpp:257
Quaternion operator-() const
Negate the quaternion, which is the same rotation.
Definition attitude-utils.cpp:265
EulerAngles ToSpherical() const
Converts this Quarterion to a new system of Euler Angles by extracting the rotations described by thi...
Definition attitude-utils.cpp:313
decimal k
The k component.
Definition attitude-utils.hpp:607
void SetVector(const Vec3 &)
Set imaginary components of Quarterion.
Definition attitude-utils.cpp:277
A Vec3 is a mutable object that represents a 3D Vector.
Definition attitude-utils.hpp:98
Mat3 OuterProduct(const Vec3 &) const
Computes the outer product between this and another vector.
Definition attitude-utils.cpp:106
decimal z
The z coordinate.
Definition attitude-utils.hpp:105
decimal y
The y coordinate.
Definition attitude-utils.hpp:103
Vec3 operator-() const
Vector Negation.
Definition attitude-utils.cpp:61
Vec3 & operator+=(const Vec3 &)
Vector Addition (Modification)
Definition attitude-utils.cpp:82
decimal Magnitude() const
Provides the magnitude of this Vec3.
Definition attitude-utils.cpp:46
decimal operator*(const Vec3 &) const
Dot Product.
Definition attitude-utils.cpp:70
Vec3 operator/(const decimal &) const
Scalar Division.
Definition attitude-utils.cpp:78
constexpr Vec3(decimal x, decimal y, decimal z)
Construction of vector with x, y, and z components.
Definition attitude-utils.hpp:114
decimal MagnitudeSq() const
Provides the square of the magnitude of this Vec3.
Definition attitude-utils.cpp:50
Vec3 CrossProduct(const Vec3 &) const
Computes the cross (vector) product between this and another vector.
Definition attitude-utils.cpp:98
decimal x
The x coordinate.
Definition attitude-utils.hpp:101
Vec3 Normalize() const
Provides the magnitude of this Vec2.
Definition attitude-utils.cpp:54
Vec3()=default
Default construction of the Vector.
A Vec2 is an immutable object that represents a 2D Vector.
Definition attitude-utils.hpp:22
decimal operator*(const Vec2 &other) const
Dot product (Scalar product)
Definition attitude-utils.cpp:30
Vec2 operator+(const Vec2 &other) const
Vector Addition.
Definition attitude-utils.cpp:38
Vec2 operator-(const Vec2 &other) const
Vector Subtraction.
Definition attitude-utils.cpp:42
decimal y
The y coordinate.
Definition attitude-utils.hpp:26
decimal x
The x coordinate.
Definition attitude-utils.hpp:24
Vec2 Normalize() const
Normalizes this.
Definition attitude-utils.cpp:23
decimal MagnitudeSq() const
Provides the square of the magnitude of this Vec2.
Definition attitude-utils.cpp:19
decimal Magnitude() const
Provides the magnitude of this Vec2.
Definition attitude-utils.cpp:15