darts/math.h file

Contains various classes for linear algebra: vectors, matrices, rays, axis-aligned bounding boxes.

Functions

template<typename T>
auto coordinate_system(const Vec3<T>& z) -> std::pair<Vec3<T>, Vec3<T>>
Construct an orthonormal coordinate system given one vector a.

Math constants

A few useful constants

#define M_PI
$\pi$
#define INV_PI
$\frac{1}{\pi}$
#define INV_TWOPI
$\frac{1}{2\pi}$
#define INV_FOURPI
$\frac{1}{4\pi}$
#define SQRT_TWO
$\sqrt{2}$
#define INV_SQRT_TWO
$\frac{1}{\sqrt{2}}$

Basic darts vector/matrix/color types

template<int N, class T>
using Vec = la::vec<T, N>
Generic N dimensional vector.
template<class T, int M, int N>
using Mat = la::mat<T, M, N>
Generic M x N matrix.
template<int N, class T>
using Color = la::vec<T, N>
Generic N dimensional color.
template<class T>
using Color3 = Color<3, T>
RGB color of type T.
template<class T>
using Color4 = Color<4, T>
RGBA color of type T.

Interpolation utilities

template<typename T>
auto mod(T a, T b) -> T
Always-positive modulo operation.

Color utilities

Working with colors

auto to_sRGB(const Color3f& c) -> Color3f
Convert from linear RGB to sRGB.
auto to_linear_RGB(const Color3f& c) -> Color3f
Convert from sRGB to linear RGB.
auto luminance(const Color3f& c) -> float
Return the associated luminance.
auto viridis(float t) -> Color3f
Evaluate the Matplotlib viridis colormap.
auto inferno(float t) -> Color3f
Evaluate the Matplotlib inferno colormap.
auto magma(float t) -> Color3f
Evaluate the Matplotlib magma colormap.
auto plasma(float t) -> Color3f
Evaluate the Matplotlib plasma colormap.