Skip to content

Class FixedVector3D

template <typename Derived>

ClassList > FixedVector3D

A 3D vector class with specialized fixed-point arithmetic. More...

  • #include <spatial.h>

Inherits the following classes: Vector3D

Public Types

Type Name
typedef Vector3D< fixed, Derived > Vec

Public Types inherited from Vector3D

See Vector3D

Type Name
typedef Either< Derived, Vector3D< NumericType > > ClassType
typedef Numeric NumericType

Public Attributes inherited from Vector3D

See Vector3D

Type Name
NumericType X_coord = 0
The X-coordinate of the vector.
NumericType Y_coord = 0
The Y-coordinate of the vector.
NumericType Z_coord = 0
The Z-coordinate of the vector.

Public Static Attributes inherited from Vector3D

See Vector3D

Type Name
constexpr Vector3D< Numeric > Backward = [**Vector3D**](classVector3D.md)&lt;Numeric&gt;(0, -1, 0)
constexpr Vector3D< Numeric > Down = [**Vector3D**](classVector3D.md)&lt;Numeric&gt;(0, 0, -1)
constexpr Vector3D< Numeric > Forward = [**Vector3D**](classVector3D.md)&lt;Numeric&gt;(0, 1, 0)
constexpr Vector3D< Numeric > Left = [**Vector3D**](classVector3D.md)&lt;Numeric&gt;(-1, 0, 0)
constexpr Vector3D< Numeric > Right = [**Vector3D**](classVector3D.md)&lt;Numeric&gt;(1, 0, 0)
constexpr Vector3D< Numeric > Up = [**Vector3D**](classVector3D.md)&lt;Numeric&gt;(0, 0, 1)
constexpr NumericType rad2DegFactor = NumericType(57.2957795131)

Public Functions

Type Name
fixed angleTo (const VectorCompatible< fixed > auto & other) const
Derived cross (const VectorCompatible< fixed > auto & other) const
fixed dot (const VectorCompatible< fixed > auto & other) const
fixed magnitude () const
fixed magnitudeXY () const
fixed magnitudeXZ () const
fixed magnitudeYZ () const
Derived normalize () const
NumericType pitch () const
NumericType yaw () const

Public Functions inherited from Vector3D

See Vector3D

Type Name
constexpr ClassType FromPolarDegrees (NumericType Pitch, NumericType Yaw, NumericType Radius)
constexpr Vector3D ()
constexpr Vector3D (NumericType initial_X_coord, NumericType initial_Y_coord, NumericType initial_Z_coord)
NumericType angleTo (const VectorCompatible< NumericType > auto & other) const
Computes the angle to another vector.
ClassType cross (const VectorCompatible< NumericType > auto & other) const
Computes the cross product of two vectors.
NumericType dot (const VectorCompatible< NumericType > auto & other) const
Computes the dot product of two vectors.
NumericType magnitude () const
Computes the magnitude (length) of the vector.
NumericType magnitudeXY () const
Computes the magnitude in the XY plane.
NumericType magnitudeXZ () const
Computes the magnitude in the XZ plane.
NumericType magnitudeYZ () const
Computes the magnitude in the YZ plane.
ClassType normalize () const
Computes the normalized vector (unit vector).
operator bool () const
Checks if the vector is non-zero.
constexpr ClassType operator* (const NumericType & scalar) const
Multiplies the vector by a scalar.
ClassType operator+ (const VectorCompatible< NumericType > auto & other) const
Adds two vectors.
ClassType operator- (const VectorCompatible< NumericType > auto & other) const
Subtracts one vector from another.
ClassType operator/ (NumericType scalar) const
Divides the vector by a scalar.
NumericType pitch () const
Computes the pitch angle of the vector.
NumericType yaw () const
Computes the yaw angle of the vector.

Public Static Functions

Type Name
fixed integer_sqrt (uint64_t n)

Detailed Description

This class provides optimized implementations for magnitude, dot product, cross product, and other vector operations using fixed-point numbers to avoid floating-point arithmetic and improve performance on embedded systems. It uses the Curiously Recurring Template Pattern (CRTP) to allow derived classes to customize behavior while reusing the base implementation.

Template parameters:

  • Derived The derived class type for CRTP.

Public Types Documentation

typedef Vec

using FixedVector3D< Derived >::Vec =  Vector3D<fixed, Derived>;

Public Functions Documentation

function angleTo

inline fixed FixedVector3D::angleTo (
    const VectorCompatible < fixed > auto & other
) const

function cross

inline Derived FixedVector3D::cross (
    const VectorCompatible < fixed > auto & other
) const

function dot

inline fixed FixedVector3D::dot (
    const VectorCompatible < fixed > auto & other
) const

function magnitude

inline fixed FixedVector3D::magnitude () const

function magnitudeXY

inline fixed FixedVector3D::magnitudeXY () const

function magnitudeXZ

inline fixed FixedVector3D::magnitudeXZ () const

function magnitudeYZ

inline fixed FixedVector3D::magnitudeYZ () const

function normalize

inline Derived FixedVector3D::normalize () const

function pitch

inline NumericType FixedVector3D::pitch () const

function yaw

inline NumericType FixedVector3D::yaw () const

Public Static Functions Documentation

function integer_sqrt

static inline fixed FixedVector3D::integer_sqrt (
    uint64_t n
) 


The documentation for this class was generated from the following file spatial.h