Class Vector3D
template <typename Numeric, typename Derived>
A generic 3D vector class. More...
#include <vector.hpp>
Inherited by the following classes: FixedVector3D, FixedVector3D, FixedVector3D
Public Types
| Type | Name |
|---|---|
| typedef Either< Derived, Vector3D< NumericType > > | ClassType |
| typedef Numeric | NumericType |
Public Attributes
| Type | Name |
|---|---|
| NumericType | X_coord = 0The X-coordinate of the vector. |
| NumericType | Y_coord = 0The Y-coordinate of the vector. |
| NumericType | Z_coord = 0The Z-coordinate of the vector. |
Public Static Attributes
| Type | Name |
|---|---|
| constexpr Vector3D< Numeric > | Backward = [**Vector3D**](classVector3D.md)<Numeric>(0, -1, 0) |
| constexpr Vector3D< Numeric > | Down = [**Vector3D**](classVector3D.md)<Numeric>(0, 0, -1) |
| constexpr Vector3D< Numeric > | Forward = [**Vector3D**](classVector3D.md)<Numeric>(0, 1, 0) |
| constexpr Vector3D< Numeric > | Left = [**Vector3D**](classVector3D.md)<Numeric>(-1, 0, 0) |
| constexpr Vector3D< Numeric > | Right = [**Vector3D**](classVector3D.md)<Numeric>(1, 0, 0) |
| constexpr Vector3D< Numeric > | Up = [**Vector3D**](classVector3D.md)<Numeric>(0, 0, 1) |
| constexpr NumericType | rad2DegFactor = NumericType(57.2957795131) |
Public Functions
| 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. |
Detailed Description
This class provides a foundation for 3D vector operations. It uses the Curiously Recurring Template Pattern (CRTP) to allow derived classes to customize behavior while reusing the base implementation.
Template parameters:
NumericThe numeric type for the vector's components (e.g., float, fixed-point).DerivedThe derived class type for CRTP.
Public Types Documentation
typedef ClassType
using Vector3D< Numeric, Derived >::ClassType = Either<Derived, Vector3D<NumericType> >;
typedef NumericType
using Vector3D< Numeric, Derived >::NumericType = Numeric;
Public Attributes Documentation
variable X_coord
The X-coordinate of the vector.
NumericType Vector3D< Numeric, Derived >::X_coord;
variable Y_coord
The Y-coordinate of the vector.
NumericType Vector3D< Numeric, Derived >::Y_coord;
variable Z_coord
The Z-coordinate of the vector.
NumericType Vector3D< Numeric, Derived >::Z_coord;
Public Static Attributes Documentation
variable Backward
constexpr Vector3D<Numeric> Vector3D< Numeric, Derived >::Backward;
variable Down
constexpr Vector3D<Numeric> Vector3D< Numeric, Derived >::Down;
variable Forward
constexpr Vector3D<Numeric> Vector3D< Numeric, Derived >::Forward;
variable Left
constexpr Vector3D<Numeric> Vector3D< Numeric, Derived >::Left;
variable Right
constexpr Vector3D<Numeric> Vector3D< Numeric, Derived >::Right;
variable Up
constexpr Vector3D<Numeric> Vector3D< Numeric, Derived >::Up;
variable rad2DegFactor
constexpr NumericType Vector3D< Numeric, Derived >::rad2DegFactor;
Public Functions Documentation
function FromPolarDegrees
inline constexpr ClassType Vector3D::FromPolarDegrees (
NumericType Pitch,
NumericType Yaw,
NumericType Radius
)
function Vector3D [1/2]
inline explicit constexpr Vector3D::Vector3D ()
function Vector3D [2/2]
inline constexpr Vector3D::Vector3D (
NumericType initial_X_coord,
NumericType initial_Y_coord,
NumericType initial_Z_coord
)
function angleTo
Computes the angle to another vector.
inline NumericType Vector3D::angleTo (
const VectorCompatible < NumericType > auto & other
) const
function cross
Computes the cross product of two vectors.
inline ClassType Vector3D::cross (
const VectorCompatible < NumericType > auto & other
) const
function dot
Computes the dot product of two vectors.
inline NumericType Vector3D::dot (
const VectorCompatible < NumericType > auto & other
) const
function magnitude
Computes the magnitude (length) of the vector.
inline NumericType Vector3D::magnitude () const
function magnitudeXY
Computes the magnitude in the XY plane.
inline NumericType Vector3D::magnitudeXY () const
function magnitudeXZ
Computes the magnitude in the XZ plane.
inline NumericType Vector3D::magnitudeXZ () const
function magnitudeYZ
Computes the magnitude in the YZ plane.
inline NumericType Vector3D::magnitudeYZ () const
function normalize
Computes the normalized vector (unit vector).
inline ClassType Vector3D::normalize () const
function operator bool
Checks if the vector is non-zero.
inline Vector3D::operator bool () const
function operator*
Multiplies the vector by a scalar.
inline constexpr ClassType Vector3D::operator* (
const NumericType & scalar
) const
function operator+
Adds two vectors.
inline ClassType Vector3D::operator+ (
const VectorCompatible < NumericType > auto & other
) const
function operator-
Subtracts one vector from another.
inline ClassType Vector3D::operator- (
const VectorCompatible < NumericType > auto & other
) const
function operator/
Divides the vector by a scalar.
inline ClassType Vector3D::operator/ (
NumericType scalar
) const
function pitch
Computes the pitch angle of the vector.
inline NumericType Vector3D::pitch () const
function yaw
Computes the yaw angle of the vector.
inline NumericType Vector3D::yaw () const
Friends Documentation
friend operator<<
inline std::ostream & Vector3D::operator<< (
std::ostream & os,
const ClassType & obj
)
The documentation for this class was generated from the following file vector.hpp