scsl 1.0.1
Shimmering Clarity Standard Library
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
scmp::geom Namespace Reference

Geometry-related code. More...

Classes

class  Point2D
 Point2D is a cartesian (X,Y) pairing. More...
 
class  Polar2D
 Polar2D is a pairing of a radius r and angle θ from some reference point; in this library, it is assumed to be the Cartesian origin (0, 0). More...
 
class  Quaternion
 Quaternions provide a representation of Orientation and rotations in three dimensions. More...
 
class  Vector
 Vectors represent a direction and Magnitude. More...
 

Typedefs

typedef Quaternion< floatQuaternionf
 Type alias for a float Quaternion.
 
typedef Quaternion< doubleQuaterniond
 Type alias for a double Quaternion.
 
typedef Vector< float, 2 > Vector2F
 Type alias for a two-dimensional float vector.
 
typedef Vector< float, 3 > Vector3F
 Type alias for a three-dimensional float vector.
 
typedef Vector< float, 4 > Vector4F
 Type alias for a four-dimensional float vector.
 
typedef Vector< double, 2 > Vector2D
 Type alias for a two-dimensional double vector.
 
typedef Vector< double, 3 > Vector3D
 Type alias for a three-dimensional double vector.
 
typedef Vector< double, 4 > Vector4D
 Type alias for a four-dimensional double vector.
 

Functions

float Heading2F (Vector2F vec)
 Compass heading for a Vector2F.
 
double Heading2D (Vector2D vec)
 Compass heading for a Vector2D.
 
float Heading3F (Vector3F vec)
 Compass heading for a Vector2F.
 
double Heading3D (Vector3D vec)
 
Quaternionf MakeQuaternion (Vector3F axis, float angle)
 Convenience Quaternion construction function.
 
Quaterniond MakeQuaternion (Vector3D axis, double angle)
 Convience Quaternion construction function.
 
template<typename T >
Quaternion< T > MakeQuaternion (Vector< T, 3 > axis, T angle)
 Convience Quaternion construction function.
 
Quaternionf FloatQuaternionFromEuler (Vector3F euler)
 COnstruct a Quaternion from Euler angles.
 
Quaterniond DoubleQuaternionFromEuler (Vector3D euler)
 COnstruct a Quaternion from Euler angles.
 
template<typename T >
Quaternion< TLERP (Quaternion< T > p, Quaternion< T > q, T t)
 Linear interpolation for two Quaternions.
 
template<typename T >
Quaternion< TShortestSLERP (Quaternion< T > p, Quaternion< T > q, T t)
 Shortest distance spherical linear interpolation.
 
void QuaternionSelfTest ()
 Internal consistency check.
 

Variables

constexpr uint8_t BasisX = 0
 Convenience constant for the x index.
 
constexpr uint8_t BasisY = 1
 Convenience constant for the y index.
 
constexpr uint8_t BasisZ = 2
 Convenience constant for the z index.
 

Detailed Description

Geometry-related code.

Function Documentation

◆ DoubleQuaternionFromEuler()

Quaterniond DoubleQuaternionFromEuler ( Vector3D  euler)

COnstruct a Quaternion from Euler angles.

Given a vector of Euler angles in ZYX sequence (e.g. yaw, pitch, roll), return a Quaternion.

Parameters
eulerA vector Euler Angle in ZYX sequence.
Returns
A Quaternion representation of the Orientation represented by the Euler angles.

◆ FloatQuaternionFromEuler()

Quaternionf FloatQuaternionFromEuler ( Vector3F  euler)

COnstruct a Quaternion from Euler angles.

Given a vector of Euler angles in ZYX sequence (e.g. yaw, pitch, roll), return a Quaternion.

Parameters
eulerA vector Euler Angle in ZYX sequence.
Returns
A Quaternion representation of the Orientation represented by the Euler angles.

◆ Heading2D()

double scmp::geom::Heading2D ( Vector2D  vec)

Compass heading for a Vector2D.

Parameters
vecA vector Orientation.
Returns
The compass heading of the vector in radians.

◆ Heading2F()

float scmp::geom::Heading2F ( Vector2F  vec)

Compass heading for a Vector2F.

Parameters
vecA vector Orientation.
Returns
The compass heading of the vector in radians.

◆ Heading3D()

double scmp::geom::Heading3D ( Vector3D  vec)

Heading3D returns a compass heading for a Vector2F.

Parameters
vecA vector Orientation.
Returns
The compass heading of the vector in radians.

◆ Heading3F()

float scmp::geom::Heading3F ( Vector3F  vec)

Compass heading for a Vector2F.

Parameters
vecA vector Orientation.
Returns
The compass heading of the vector in radians.

◆ LERP()

template<typename T >
Quaternion< T > scmp::geom::LERP ( Quaternion< T p,
Quaternion< T q,
T  t 
)

Linear interpolation for two Quaternions.

LERP computes the linear interpolation of two quaternions At some fraction of the distance between them.

Template Parameters
T
Parameters
pThe starting Quaternion.
qThe ending Quaternion.
tThe fraction of the distance between the two quaternions to interpolate.
Returns
A Quaternion representing the linear interpolation of the two quaternions.

◆ MakeQuaternion() [1/3]

Quaterniond MakeQuaternion ( Vector3D  axis,
double  angle 
)

Convience Quaternion construction function.

Return a double Quaternion scaled appropriately from a vector and Angle, e.g. Angle = cos(Angle / 2), Axis.UnitVector() * sin(Angle / 2).

Parameters
axisThe Axis of rotation.
angleThe Angle of rotation.
Returns
A Quaternion.

◆ MakeQuaternion() [2/3]

Quaternionf MakeQuaternion ( Vector3F  axis,
float  angle 
)

Convenience Quaternion construction function.

Return a float Quaternion scaled appropriately from a vector and Angle, e.g. angle = cos(Angle / 2), Axis.UnitVector() * sin(Angle / 2).

Parameters
axisThe Axis of rotation.
angleThe Angle of rotation.
Returns
A Quaternion.

◆ MakeQuaternion() [3/3]

template<typename T >
Quaternion< T > MakeQuaternion ( Vector< T, 3 >  axis,
angle 
)

Convience Quaternion construction function.

Return a double Quaternion scaled appropriately from a vector and Angle, e.g. Angle = cos(Angle / 2), Axis.UnitVector() * sin(Angle / 2).

Parameters
axisThe Axis of rotation.
angleThe Angle of rotation.
Returns
A Quaternion.

◆ QuaternionSelfTest()

void scmp::geom::QuaternionSelfTest ( )

Internal consistency check.

Run a quick self test to exercise basic functionality of the Quaternion class to verify correct operation. Note that if #NDEBUG is defined, the self test is disabled.

◆ ShortestSLERP()

template<typename T >
Quaternion< T > scmp::geom::ShortestSLERP ( Quaternion< T p,
Quaternion< T q,
T  t 
)

Shortest distance spherical linear interpolation.

ShortestSLERP computes the shortest distance spherical linear interpolation between two unit quaternions At some fraction of the distance between them.

Template Parameters
T
Parameters
pThe starting Quaternion.
qThe ending Quaternion.
tThe fraction of the distance between the two quaternions to interpolate.
Returns
A Quaternion representing the shortest path between two quaternions.