Math module

Fixed-size vectors/colors, matrices, transforms, rays, orthonormal bases.

Classes

template<int N, typename T>
struct Box
An N-D axis-aligned bounding box consisting of two N-D points min and max.
template<size_t N, typename T>
struct Ray
Simple ray segment data structure.
struct Transform
Homogeneous coordinate transformation.

Typedefs

template<typename T>
using Box2 = Box<2, T>
2D axis-aligned box
template<typename T>
using Box3 = Box<3, T>
3D axis-aligned box
template<typename T>
using Box4 = Box<4, T>
4D axis-aligned box
using Box2f = Box2<float>
2D axis-aligned box (of floats)
using Box2d = Box2<double>
2D axis-aligned box (of doubles)
using Box2i = Box2<int32_t>
2D axis-aligned box (of signed 32-bit integers)
using Box2u = Box2<uint32_t>
2D axis-aligned box (of unsigned 32-bit integers
using Box2c = Box2<uint8_t>
2D axis-aligned box (of unsigned 8-bit integers
using Box3f = Box3<float>
3D axis-aligned box (of floats)
using Box3d = Box3<double>
3D axis-aligned box (of doubles)
using Box3i = Box3<int32_t>
3D axis-aligned box (of signed 32-bit integers)
using Box3u = Box3<uint32_t>
3D axis-aligned box (of unsigned 32-bit integers
using Box3c = Box3<uint8_t>
3D axis-aligned box (of unsigned 8-bit integers
using Box4f = Box4<float>
4D axis-aligned box (of floats)
using Box4d = Box4<double>
4D axis-aligned box (of doubles)
using Box4i = Box4<int32_t>
4D axis-aligned box (of signed 32-bit integers)
using Box4u = Box4<uint32_t>
4D axis-aligned box (of unsigned 32-bit integers
using Box4c = Box4<uint8_t>
4D axis-aligned box (of unsigned 8-bit integers
template<typename T>
using Ray2 = Ray<2, T>
2D ray
template<typename T>
using Ray3 = Ray<3, T>
3D ray
using Ray2f = Ray2<float>
2D floating-point ray
using Ray2d = Ray2<double>
2D double-precision ray
using Ray3f = Ray3<float>
3D floating-point ray
using Ray3d = Ray3<double>
3D double-precision ray
template<int N, class T>
using Vec = linalg::vec<T, N>
Generic N dimensional vector.
template<class T, int M, int N>
using Mat = linalg::mat<T, M, N>
Generic M x N matrix.
template<class T>
using Vec2 = Vec<2, T>
2D vector of type T
template<class T>
using Vec3 = Vec<3, T>
3D vector of type T
template<class T>
using Vec4 = Vec<4, T>
4D vector of type T
template<class T>
using Color3 = Vec<3, T>
RGB color of type T.
template<class T>
using Color4 = Vec<4, T>
RGBA color of type T.
using Vec2f = Vec2<float>
2D float vector
using Vec2d = Vec2<double>
2D double vector
using Vec2i = Vec2<std::int32_t>
2D integer vector (32-bit)
using Vec2u = Vec2<std::uint32_t>
2D unsigned vector (32-bit)
using Vec2c = Vec2<std::uint8_t>
2D character vector (8-bit unsigned integers)
using Vec3f = Vec3<float>
3D float vector
using Vec3d = Vec3<double>
3D double vector
using Vec3i = Vec3<std::int32_t>
3D integer vector (32-bit)
using Vec3u = Vec3<std::uint32_t>
3D unsigned vector (32-bit)
using Vec3c = Vec3<std::uint8_t>
3D character vector (8-bit unsigned integers)
using Color3f = Vec3<float>
RGB float color.
using Color3d = Vec3<double>
RGB double color.
using Color3u = Vec3<std::uint32_t>
RGB 32-bit unsigned integer color.
using Color3c = Vec3<std::uint8_t>
RGB 8-bit unsigned integer.
using Vec4f = Vec4<float>
4D float vector
using Vec4d = Vec4<double>
4D double vector
using Vec4i = Vec4<std::int32_t>
4D integer vector (32-bit)
using Vec4u = Vec4<std::uint32_t>
4D unsigned vector (32-bit)
using Vec4c = Vec4<std::uint8_t>
4D character vector (8-bit unsigned integers)
using Color4f = Vec4<float>
RGBA float color.
using Color4d = Vec4<double>
RGBA double color.
using Color4u = Vec4<std::uint32_t>
RGBA 32-bit unsigned integer color.
using Color4c = Vec4<std::uint8_t>
RGBA 8-bit unsigned integer.
template<class T>
using Mat22 = linalg::mat<T, 2, 2>
A generic 2x2 matrix.
template<class T>
using Mat33 = linalg::mat<T, 3, 3>
A generic 3x3 matrix.
template<class T>
using Mat44 = linalg::mat<T, 4, 4>
A generic 4x4 matrix.
using Mat22f = Mat22<float>
2x2 float matrix
using Mat22d = Mat22<double>
2x2 double matrix
using Mat33f = Mat33<float>
3x3 float matrix
using Mat33d = Mat33<double>
3x3 double matrix
using Mat44f = Mat44<float>
4x4 float matrix
using Mat44d = Mat44<double>
4x4 double matrix

Functions

template<typename T>
void coordinate_system(const Vec3<T>& a, Vec3<T>& b, Vec3<T>& c)
Construct an orthonormal coordinate system given one vector a.
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 is_valid_color(const Color3f& c) -> bool
Check if the color vector contains a NaN/Inf/negative value.
auto luminance(const Color3f& c) -> float
Return the associated luminance.

Typedef documentation

#include <darts/box.h>
template<typename T>
using Box2 = Box<2, T>

2D axis-aligned box

#include <darts/box.h>
template<typename T>
using Box3 = Box<3, T>

3D axis-aligned box

#include <darts/box.h>
template<typename T>
using Box4 = Box<4, T>

4D axis-aligned box

using Box2f = Box2<float>
#include <darts/box.h>

2D axis-aligned box (of floats)

using Box2d = Box2<double>
#include <darts/box.h>

2D axis-aligned box (of doubles)

using Box2i = Box2<int32_t>
#include <darts/box.h>

2D axis-aligned box (of signed 32-bit integers)

using Box2u = Box2<uint32_t>
#include <darts/box.h>

2D axis-aligned box (of unsigned 32-bit integers

using Box2c = Box2<uint8_t>
#include <darts/box.h>

2D axis-aligned box (of unsigned 8-bit integers

using Box3f = Box3<float>
#include <darts/box.h>

3D axis-aligned box (of floats)

using Box3d = Box3<double>
#include <darts/box.h>

3D axis-aligned box (of doubles)

using Box3i = Box3<int32_t>
#include <darts/box.h>

3D axis-aligned box (of signed 32-bit integers)

using Box3u = Box3<uint32_t>
#include <darts/box.h>

3D axis-aligned box (of unsigned 32-bit integers

using Box3c = Box3<uint8_t>
#include <darts/box.h>

3D axis-aligned box (of unsigned 8-bit integers

using Box4f = Box4<float>
#include <darts/box.h>

4D axis-aligned box (of floats)

using Box4d = Box4<double>
#include <darts/box.h>

4D axis-aligned box (of doubles)

using Box4i = Box4<int32_t>
#include <darts/box.h>

4D axis-aligned box (of signed 32-bit integers)

using Box4u = Box4<uint32_t>
#include <darts/box.h>

4D axis-aligned box (of unsigned 32-bit integers

using Box4c = Box4<uint8_t>
#include <darts/box.h>

4D axis-aligned box (of unsigned 8-bit integers

#include <darts/ray.h>
template<typename T>
using Ray2 = Ray<2, T>

2D ray

#include <darts/ray.h>
template<typename T>
using Ray3 = Ray<3, T>

3D ray

using Ray2f = Ray2<float>
#include <darts/ray.h>

2D floating-point ray

using Ray2d = Ray2<double>
#include <darts/ray.h>

2D double-precision ray

using Ray3f = Ray3<float>
#include <darts/ray.h>

3D floating-point ray

using Ray3d = Ray3<double>
#include <darts/ray.h>

3D double-precision ray

#include <darts/vec.h>
template<int N, class T>
using Vec = linalg::vec<T, N>

Generic N dimensional vector.

#include <darts/vec.h>
template<class T, int M, int N>
using Mat = linalg::mat<T, M, N>

Generic M x N matrix.

#include <darts/vec.h>
template<class T>
using Vec2 = Vec<2, T>

2D vector of type T

#include <darts/vec.h>
template<class T>
using Vec3 = Vec<3, T>

3D vector of type T

#include <darts/vec.h>
template<class T>
using Vec4 = Vec<4, T>

4D vector of type T

#include <darts/vec.h>
template<class T>
using Color3 = Vec<3, T>

RGB color of type T.

#include <darts/vec.h>
template<class T>
using Color4 = Vec<4, T>

RGBA color of type T.

using Vec2f = Vec2<float>
#include <darts/vec.h>

2D float vector

using Vec2d = Vec2<double>
#include <darts/vec.h>

2D double vector

using Vec2i = Vec2<std::int32_t>
#include <darts/vec.h>

2D integer vector (32-bit)

using Vec2u = Vec2<std::uint32_t>
#include <darts/vec.h>

2D unsigned vector (32-bit)

using Vec2c = Vec2<std::uint8_t>
#include <darts/vec.h>

2D character vector (8-bit unsigned integers)

using Vec3f = Vec3<float>
#include <darts/vec.h>

3D float vector

using Vec3d = Vec3<double>
#include <darts/vec.h>

3D double vector

using Vec3i = Vec3<std::int32_t>
#include <darts/vec.h>

3D integer vector (32-bit)

using Vec3u = Vec3<std::uint32_t>
#include <darts/vec.h>

3D unsigned vector (32-bit)

using Vec3c = Vec3<std::uint8_t>
#include <darts/vec.h>

3D character vector (8-bit unsigned integers)

using Color3f = Vec3<float>
#include <darts/vec.h>

RGB float color.

using Color3d = Vec3<double>
#include <darts/vec.h>

RGB double color.

using Color3u = Vec3<std::uint32_t>
#include <darts/vec.h>

RGB 32-bit unsigned integer color.

using Color3c = Vec3<std::uint8_t>
#include <darts/vec.h>

RGB 8-bit unsigned integer.

using Vec4f = Vec4<float>
#include <darts/vec.h>

4D float vector

using Vec4d = Vec4<double>
#include <darts/vec.h>

4D double vector

using Vec4i = Vec4<std::int32_t>
#include <darts/vec.h>

4D integer vector (32-bit)

using Vec4u = Vec4<std::uint32_t>
#include <darts/vec.h>

4D unsigned vector (32-bit)

using Vec4c = Vec4<std::uint8_t>
#include <darts/vec.h>

4D character vector (8-bit unsigned integers)

using Color4f = Vec4<float>
#include <darts/vec.h>

RGBA float color.

using Color4d = Vec4<double>
#include <darts/vec.h>

RGBA double color.

using Color4u = Vec4<std::uint32_t>
#include <darts/vec.h>

RGBA 32-bit unsigned integer color.

using Color4c = Vec4<std::uint8_t>
#include <darts/vec.h>

RGBA 8-bit unsigned integer.

#include <darts/vec.h>
template<class T>
using Mat22 = linalg::mat<T, 2, 2>

A generic 2x2 matrix.

#include <darts/vec.h>
template<class T>
using Mat33 = linalg::mat<T, 3, 3>

A generic 3x3 matrix.

#include <darts/vec.h>
template<class T>
using Mat44 = linalg::mat<T, 4, 4>

A generic 4x4 matrix.

using Mat22f = Mat22<float>
#include <darts/vec.h>

2x2 float matrix

using Mat22d = Mat22<double>
#include <darts/vec.h>

2x2 double matrix

using Mat33f = Mat33<float>
#include <darts/vec.h>

3x3 float matrix

using Mat33d = Mat33<double>
#include <darts/vec.h>

3x3 double matrix

using Mat44f = Mat44<float>
#include <darts/vec.h>

4x4 float matrix

using Mat44d = Mat44<double>
#include <darts/vec.h>

4x4 double matrix

Function documentation

#include <darts/vec.h>
template<typename T>
void coordinate_system(const Vec3<T>& a, Vec3<T>& b, Vec3<T>& c)

Construct an orthonormal coordinate system given one vector a.

Parameters
a [in] The coordinate system's local z axis direction.
b [out] A local x-axis orthogonal to a.
c [out] A local y-axis orthogonal to both a and b.

Color3f to_sRGB(const Color3f& c)
#include <darts/vec.h>

Convert from linear RGB to sRGB.

Color3f to_linear_RGB(const Color3f& c)
#include <darts/vec.h>

Convert from sRGB to linear RGB.

bool is_valid_color(const Color3f& c)
#include <darts/vec.h>

Check if the color vector contains a NaN/Inf/negative value.

float luminance(const Color3f& c)
#include <darts/vec.h>

Return the associated luminance.