Fx2D
A C++20 2D rigid-body physics engine
Loading...
Searching...
No Matches
Math.h File Reference
#include <Eigen/Core>
#include <algorithm>
#include <concepts>
#include <cstdint>
#include <initializer_list>
#include <iostream>
#include <memory>
#include <numbers>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
+ Include dependency graph for Math.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FxVec2f
 Single-precision 2D vector. More...
 
class  FxVec2d
 Double-precision 2D vector. More...
 
class  FxVec3f
 Single-precision three-component vector, including poses. More...
 
class  FxVec3d
 Double-precision three-component vector. More...
 
class  FxVec4f
 Four-component floating-point vector. More...
 
class  FxVec2ui
 
class  FxVec4ui8
 
class  FxMat2f
 2×2 floating-point matrix. More...
 
class  FxMat3f
 3×3 floating-point matrix. More...
 
struct  FxArrayAlignedDelete< T >
 
class  FxArray< T >
 Fixed-size, aligned value array. More...
 

Concepts

concept  Numeric
 
concept  NumericOrFxVec
 
concept  FxVecT
 
concept  ConvertibleOrNumeric
 

Typedefs

using FxVec2fMap = Eigen::Map< Eigen::Vector2f >
 
using FxVec2dMap = Eigen::Map< Eigen::Vector2d >
 
using FxVec2fArray = FxArray< FxVec2f >
 

Functions

template<Numeric S>
FxVec2f operator* (FxVec2f const &v, S s)
 
template<Numeric S>
FxVec2f operator* (S s, FxVec2f const &v)
 
template<Numeric S>
FxVec2f operator/ (FxVec2f const &v, S s)
 
template<Numeric S>
FxVec2f operator+ (FxVec2f const &v, S s)
 
template<Numeric S>
FxVec2f operator+ (S s, FxVec2f const &v)
 
template<Numeric S>
FxVec2f operator- (FxVec2f const &v, S s)
 
template<Numeric S>
FxVec2f operator- (S s, FxVec2f const &v)
 
template<Numeric S>
FxVec3f operator* (FxVec3f const &v, S s)
 
template<Numeric S>
FxVec3f operator* (S s, FxVec3f const &v)
 
template<Numeric S>
FxVec3f operator/ (FxVec3f const &v, S s)
 
template<Numeric S>
FxVec3f operator+ (FxVec3f const &v, S s)
 
template<Numeric S>
FxVec3f operator+ (S s, FxVec3f const &v)
 
template<Numeric S>
FxVec3f operator- (FxVec3f const &v, S s)
 
template<Numeric S>
FxVec3f operator- (S s, FxVec3f const &v)
 
template<Numeric S>
FxVec2d operator* (FxVec2d const &v, S s)
 
template<Numeric S>
FxVec2d operator* (S s, FxVec2d const &v)
 
template<Numeric S>
FxVec2d operator/ (FxVec2d const &v, S s)
 
template<Numeric S>
FxVec2d operator+ (FxVec2d const &v, S s)
 
template<Numeric S>
FxVec2d operator+ (S s, FxVec2d const &v)
 
template<Numeric S>
FxVec2d operator- (FxVec2d const &v, S s)
 
template<Numeric S>
FxVec2d operator- (S s, FxVec2d const &v)
 
template<Numeric S>
FxVec3d operator* (FxVec3d const &v, S s)
 
template<Numeric S>
FxVec3d operator* (S s, FxVec3d const &v)
 
template<Numeric S>
FxVec3d operator/ (FxVec3d const &v, S s)
 
template<Numeric S>
FxVec3d operator+ (FxVec3d const &v, S s)
 
template<Numeric S>
FxVec3d operator+ (S s, FxVec3d const &v)
 
template<Numeric S>
FxVec3d operator- (FxVec3d const &v, S s)
 
template<Numeric S>
FxVec3d operator- (S s, FxVec3d const &v)
 
template<Numeric S>
FxVec4f operator* (FxVec4f const &v, S s)
 
template<Numeric S>
FxVec4f operator* (S s, FxVec4f const &v)
 
template<Numeric S>
FxVec4f operator/ (FxVec4f const &v, S s)
 
template<Numeric S>
FxVec4f operator+ (FxVec4f const &v, S s)
 
template<Numeric S>
FxVec4f operator+ (S s, FxVec4f const &v)
 
template<Numeric S>
FxVec4f operator- (FxVec4f const &v, S s)
 
template<Numeric S>
FxVec4f operator- (S s, FxVec4f const &v)
 
template<Numeric S>
FxVec2f & operator+= (FxVec2f &v, S s)
 
template<Numeric S>
FxVec2f & operator-= (FxVec2f &v, S s)
 
template<Numeric S>
FxVec2f & operator*= (FxVec2f &v, S s)
 
template<Numeric S>
FxVec2f & operator/= (FxVec2f &v, S s)
 
template<Numeric S>
FxVec3f & operator+= (FxVec3f &v, S s)
 
template<Numeric S>
FxVec3f & operator-= (FxVec3f &v, S s)
 
template<Numeric S>
FxVec3f & operator*= (FxVec3f &v, S s)
 
template<Numeric S>
FxVec3f & operator/= (FxVec3f &v, S s)
 
template<Numeric S>
FxVec4f & operator+= (FxVec4f &v, S s)
 
template<Numeric S>
FxVec4f & operator-= (FxVec4f &v, S s)
 
template<Numeric S>
FxVec4f & operator*= (FxVec4f &v, S s)
 
template<Numeric S>
FxVec4f & operator/= (FxVec4f &v, S s)
 
FxVec2f & operator*= (FxVec2f &lhs, const FxVec2f &rhs)
 
FxVec2f & operator/= (FxVec2f &lhs, const FxVec2f &rhs)
 
FxVec2f & operator+= (FxVec2f &lhs, const FxVec2f &rhs)
 
FxVec2f & operator-= (FxVec2f &lhs, const FxVec2f &rhs)
 
template<Numeric S>
FxVec2f operator/ (S s, FxVec2f const &v)
 
template<Numeric S>
FxVec3f operator/ (S s, FxVec3f const &v)
 
template<Numeric S>
FxVec4f operator/ (S s, FxVec4f const &v)
 
template<NumericOrFxVec T>
void swap (FxArray< T > &a, FxArray< T > &b) noexcept
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator+ (FxArray< T > a, U const &scalar)
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator- (FxArray< T > a, U const &scalar)
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator* (FxArray< T > a, U const &scalar)
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator/ (FxArray< T > a, U const &scalar)
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator+ (U const &scalar, FxArray< T > a)
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator* (U const &scalar, FxArray< T > a)
 
template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator- (U const &scalar, FxArray< T > a)
 
template<typename T , Numeric U>
FxArray< T > operator/ (U const &scalar, FxArray< T > const &a)
 
template<typename T >
FxArray< T > operator/ (T const &scalar, FxArray< T > const &a)
 
template<typename T >
FxArray< T > operator+ (FxArray< T > a, const FxArray< T > &b)
 
template<typename T >
FxArray< T > operator- (FxArray< T > a, const FxArray< T > &b)
 
template<typename T >
FxArray< T > operator* (FxArray< T > a, const FxArray< T > &b)
 
template<typename T >
FxArray< T > operator/ (FxArray< T > a, const FxArray< T > &b)
 
template<Numeric T>
std::ostream & operator<< (std::ostream &os, FxArray< T > const &a)
 
std::ostream & operator<< (std::ostream &os, FxVec2fArray const &a)
 
std::ostream & operator<< (std::ostream &os, FxVec2f const &a)
 
std::ostream & operator<< (std::ostream &os, FxVec3f const &a)
 

Typedef Documentation

◆ FxVec2dMap

using FxVec2dMap = Eigen::Map<Eigen::Vector2d>

Definition at line 192 of file Math.h.

◆ FxVec2fArray

Definition at line 1131 of file Math.h.

◆ FxVec2fMap

using FxVec2fMap = Eigen::Map<Eigen::Vector2f>

Definition at line 156 of file Math.h.

Function Documentation

◆ operator*() [1/13]

template<typename T >
FxArray< T > operator* ( FxArray< T >  a,
const FxArray< T > &  b 
)
inline

Definition at line 1210 of file Math.h.

◆ operator*() [2/13]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator* ( FxArray< T >  a,
U const &  scalar 
)
inline

Definition at line 1148 of file Math.h.

◆ operator*() [3/13]

template<Numeric S>
FxVec2d operator* ( FxVec2d const &  v,
S  s 
)
inline

Definition at line 317 of file Math.h.

◆ operator*() [4/13]

template<Numeric S>
FxVec2f operator* ( FxVec2f const &  v,
S  s 
)
inline

Definition at line 257 of file Math.h.

◆ operator*() [5/13]

template<Numeric S>
FxVec3d operator* ( FxVec3d const &  v,
S  s 
)
inline

Definition at line 347 of file Math.h.

◆ operator*() [6/13]

template<Numeric S>
FxVec3f operator* ( FxVec3f const &  v,
S  s 
)
inline

Definition at line 287 of file Math.h.

◆ operator*() [7/13]

template<Numeric S>
FxVec4f operator* ( FxVec4f const &  v,
S  s 
)
inline

Definition at line 377 of file Math.h.

◆ operator*() [8/13]

template<Numeric S>
FxVec2d operator* ( S  s,
FxVec2d const &  v 
)
inline

Definition at line 321 of file Math.h.

◆ operator*() [9/13]

template<Numeric S>
FxVec2f operator* ( S  s,
FxVec2f const &  v 
)
inline

Definition at line 261 of file Math.h.

◆ operator*() [10/13]

template<Numeric S>
FxVec3d operator* ( S  s,
FxVec3d const &  v 
)
inline

Definition at line 351 of file Math.h.

◆ operator*() [11/13]

template<Numeric S>
FxVec3f operator* ( S  s,
FxVec3f const &  v 
)
inline

Definition at line 291 of file Math.h.

◆ operator*() [12/13]

template<Numeric S>
FxVec4f operator* ( S  s,
FxVec4f const &  v 
)
inline

Definition at line 381 of file Math.h.

◆ operator*() [13/13]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator* ( U const &  scalar,
FxArray< T >  a 
)
inline

Definition at line 1167 of file Math.h.

◆ operator*=() [1/4]

FxVec2f & operator*= ( FxVec2f &  lhs,
const FxVec2f &  rhs 
)
inline

Definition at line 472 of file Math.h.

◆ operator*=() [2/4]

template<Numeric S>
FxVec2f & operator*= ( FxVec2f &  v,
S  s 
)
inline

Definition at line 417 of file Math.h.

◆ operator*=() [3/4]

template<Numeric S>
FxVec3f & operator*= ( FxVec3f &  v,
S  s 
)
inline

Definition at line 439 of file Math.h.

◆ operator*=() [4/4]

template<Numeric S>
FxVec4f & operator*= ( FxVec4f &  v,
S  s 
)
inline

Definition at line 461 of file Math.h.

◆ operator+() [1/13]

template<typename T >
FxArray< T > operator+ ( FxArray< T >  a,
const FxArray< T > &  b 
)
inline

Definition at line 1200 of file Math.h.

◆ operator+() [2/13]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator+ ( FxArray< T >  a,
U const &  scalar 
)
inline

Definition at line 1136 of file Math.h.

◆ operator+() [3/13]

template<Numeric S>
FxVec2d operator+ ( FxVec2d const &  v,
S  s 
)
inline

Definition at line 329 of file Math.h.

◆ operator+() [4/13]

template<Numeric S>
FxVec2f operator+ ( FxVec2f const &  v,
S  s 
)
inline

Definition at line 269 of file Math.h.

◆ operator+() [5/13]

template<Numeric S>
FxVec3d operator+ ( FxVec3d const &  v,
S  s 
)
inline

Definition at line 359 of file Math.h.

◆ operator+() [6/13]

template<Numeric S>
FxVec3f operator+ ( FxVec3f const &  v,
S  s 
)
inline

Definition at line 299 of file Math.h.

◆ operator+() [7/13]

template<Numeric S>
FxVec4f operator+ ( FxVec4f const &  v,
S  s 
)
inline

Definition at line 389 of file Math.h.

◆ operator+() [8/13]

template<Numeric S>
FxVec2d operator+ ( S  s,
FxVec2d const &  v 
)
inline

Definition at line 333 of file Math.h.

◆ operator+() [9/13]

template<Numeric S>
FxVec2f operator+ ( S  s,
FxVec2f const &  v 
)
inline

Definition at line 273 of file Math.h.

◆ operator+() [10/13]

template<Numeric S>
FxVec3d operator+ ( S  s,
FxVec3d const &  v 
)
inline

Definition at line 363 of file Math.h.

◆ operator+() [11/13]

template<Numeric S>
FxVec3f operator+ ( S  s,
FxVec3f const &  v 
)
inline

Definition at line 303 of file Math.h.

◆ operator+() [12/13]

template<Numeric S>
FxVec4f operator+ ( S  s,
FxVec4f const &  v 
)
inline

Definition at line 393 of file Math.h.

◆ operator+() [13/13]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator+ ( U const &  scalar,
FxArray< T >  a 
)
inline

Definition at line 1161 of file Math.h.

◆ operator+=() [1/4]

FxVec2f & operator+= ( FxVec2f &  lhs,
const FxVec2f &  rhs 
)
inline

Definition at line 480 of file Math.h.

◆ operator+=() [2/4]

template<Numeric S>
FxVec2f & operator+= ( FxVec2f &  v,
S  s 
)
inline

Definition at line 407 of file Math.h.

◆ operator+=() [3/4]

template<Numeric S>
FxVec3f & operator+= ( FxVec3f &  v,
S  s 
)
inline

Definition at line 429 of file Math.h.

◆ operator+=() [4/4]

template<Numeric S>
FxVec4f & operator+= ( FxVec4f &  v,
S  s 
)
inline

Definition at line 451 of file Math.h.

◆ operator-() [1/13]

template<typename T >
FxArray< T > operator- ( FxArray< T >  a,
const FxArray< T > &  b 
)
inline

Definition at line 1205 of file Math.h.

◆ operator-() [2/13]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator- ( FxArray< T >  a,
U const &  scalar 
)
inline

Definition at line 1142 of file Math.h.

◆ operator-() [3/13]

template<Numeric S>
FxVec2d operator- ( FxVec2d const &  v,
S  s 
)
inline

Definition at line 337 of file Math.h.

◆ operator-() [4/13]

template<Numeric S>
FxVec2f operator- ( FxVec2f const &  v,
S  s 
)
inline

Definition at line 277 of file Math.h.

◆ operator-() [5/13]

template<Numeric S>
FxVec3d operator- ( FxVec3d const &  v,
S  s 
)
inline

Definition at line 367 of file Math.h.

◆ operator-() [6/13]

template<Numeric S>
FxVec3f operator- ( FxVec3f const &  v,
S  s 
)
inline

Definition at line 307 of file Math.h.

◆ operator-() [7/13]

template<Numeric S>
FxVec4f operator- ( FxVec4f const &  v,
S  s 
)
inline

Definition at line 397 of file Math.h.

◆ operator-() [8/13]

template<Numeric S>
FxVec2d operator- ( S  s,
FxVec2d const &  v 
)
inline

Definition at line 341 of file Math.h.

◆ operator-() [9/13]

template<Numeric S>
FxVec2f operator- ( S  s,
FxVec2f const &  v 
)
inline

Definition at line 281 of file Math.h.

◆ operator-() [10/13]

template<Numeric S>
FxVec3d operator- ( S  s,
FxVec3d const &  v 
)
inline

Definition at line 371 of file Math.h.

◆ operator-() [11/13]

template<Numeric S>
FxVec3f operator- ( S  s,
FxVec3f const &  v 
)
inline

Definition at line 311 of file Math.h.

◆ operator-() [12/13]

template<Numeric S>
FxVec4f operator- ( S  s,
FxVec4f const &  v 
)
inline

Definition at line 401 of file Math.h.

◆ operator-() [13/13]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator- ( U const &  scalar,
FxArray< T >  a 
)
inline

Definition at line 1173 of file Math.h.

◆ operator-=() [1/4]

FxVec2f & operator-= ( FxVec2f &  lhs,
const FxVec2f &  rhs 
)
inline

Definition at line 484 of file Math.h.

◆ operator-=() [2/4]

template<Numeric S>
FxVec2f & operator-= ( FxVec2f &  v,
S  s 
)
inline

Definition at line 412 of file Math.h.

◆ operator-=() [3/4]

template<Numeric S>
FxVec3f & operator-= ( FxVec3f &  v,
S  s 
)
inline

Definition at line 434 of file Math.h.

◆ operator-=() [4/4]

template<Numeric S>
FxVec4f & operator-= ( FxVec4f &  v,
S  s 
)
inline

Definition at line 456 of file Math.h.

◆ operator/() [1/12]

template<typename T >
FxArray< T > operator/ ( FxArray< T >  a,
const FxArray< T > &  b 
)
inline

Definition at line 1215 of file Math.h.

◆ operator/() [2/12]

template<typename T , typename U >
requires ConvertibleOrNumeric<U, T>
FxArray< T > operator/ ( FxArray< T >  a,
U const &  scalar 
)
inline

Definition at line 1154 of file Math.h.

◆ operator/() [3/12]

template<Numeric S>
FxVec2d operator/ ( FxVec2d const &  v,
S  s 
)
inline

Definition at line 325 of file Math.h.

◆ operator/() [4/12]

template<Numeric S>
FxVec2f operator/ ( FxVec2f const &  v,
S  s 
)
inline

Definition at line 265 of file Math.h.

◆ operator/() [5/12]

template<Numeric S>
FxVec3d operator/ ( FxVec3d const &  v,
S  s 
)
inline

Definition at line 355 of file Math.h.

◆ operator/() [6/12]

template<Numeric S>
FxVec3f operator/ ( FxVec3f const &  v,
S  s 
)
inline

Definition at line 295 of file Math.h.

◆ operator/() [7/12]

template<Numeric S>
FxVec4f operator/ ( FxVec4f const &  v,
S  s 
)
inline

Definition at line 385 of file Math.h.

◆ operator/() [8/12]

template<Numeric S>
FxVec2f operator/ ( S  s,
FxVec2f const &  v 
)
inline

Definition at line 490 of file Math.h.

◆ operator/() [9/12]

template<Numeric S>
FxVec3f operator/ ( S  s,
FxVec3f const &  v 
)
inline

Definition at line 496 of file Math.h.

◆ operator/() [10/12]

template<Numeric S>
FxVec4f operator/ ( S  s,
FxVec4f const &  v 
)
inline

Definition at line 502 of file Math.h.

◆ operator/() [11/12]

template<typename T >
FxArray< T > operator/ ( T const &  scalar,
FxArray< T > const &  a 
)
inline

Definition at line 1189 of file Math.h.

◆ operator/() [12/12]

template<typename T , Numeric U>
FxArray< T > operator/ ( U const &  scalar,
FxArray< T > const &  a 
)
inline

Definition at line 1179 of file Math.h.

◆ operator/=() [1/4]

FxVec2f & operator/= ( FxVec2f &  lhs,
const FxVec2f &  rhs 
)
inline

Definition at line 476 of file Math.h.

◆ operator/=() [2/4]

template<Numeric S>
FxVec2f & operator/= ( FxVec2f &  v,
S  s 
)
inline

Definition at line 422 of file Math.h.

◆ operator/=() [3/4]

template<Numeric S>
FxVec3f & operator/= ( FxVec3f &  v,
S  s 
)
inline

Definition at line 444 of file Math.h.

◆ operator/=() [4/4]

template<Numeric S>
FxVec4f & operator/= ( FxVec4f &  v,
S  s 
)
inline

Definition at line 466 of file Math.h.

◆ operator<<() [1/4]

template<Numeric T>
std::ostream & operator<< ( std::ostream &  os,
FxArray< T > const &  a 
)
inline

Definition at line 1220 of file Math.h.

◆ operator<<() [2/4]

std::ostream & operator<< ( std::ostream &  os,
FxVec2f const &  a 
)
inline

Definition at line 1236 of file Math.h.

◆ operator<<() [3/4]

std::ostream & operator<< ( std::ostream &  os,
FxVec2fArray const &  a 
)
inline

Definition at line 1228 of file Math.h.

◆ operator<<() [4/4]

std::ostream & operator<< ( std::ostream &  os,
FxVec3f const &  a 
)
inline

Definition at line 1243 of file Math.h.

◆ swap()

template<NumericOrFxVec T>
void swap ( FxArray< T > &  a,
FxArray< T > &  b 
)
noexcept

Definition at line 1124 of file Math.h.