Euphoria
Math

Namespaces

namespace  eu::kk

Classes

struct  eu::An
 An angle in both degrees and radians. More...
struct  eu::AA
 Axis + Angle. More...
struct  eu::Ypr
 yaw + pitch + roll More...
struct  eu::m4
 4x4 matrix More...
struct  eu::Q
 A quaternion representing a rotation in 3d. More...
struct  eu::R< T >
 A (inclusive) range between two values. More...
struct  eu::Size
 a size More...
struct  eu::v2
 a 2d vector More...
struct  eu::n2
 a 2d unit (vector) More...
struct  eu::v3
 a 3d vector More...
struct  eu::n3
 a 3d unit (vector) More...
struct  eu::v4
 A 4d vector. More...

Functions

float eu::sin (const An &ang)
float eu::cos (const An &ang)
float eu::tan (const An &ang)
An eu::asin (float v)
An eu::acos (float v)
An eu::atan (float v)
An eu::atan2 (float y, float x)
An eu::operator+ (const An &lhs, const An &rhs)
An eu::operator- (const An &lhs, const An &rhs)
An eu::operator* (const An &lhs, float rhs)
An eu::operator/ (const An &lhs, float rhs)
An eu::operator* (float rhs, const An &lhs)
std::string eu::string_from (const An &a)
bool eu::operator< (const An &lhs, const An &rhs)
bool eu::operator<= (const An &lhs, const An &rhs)
bool eu::operator> (const An &lhs, const An &rhs)
bool eu::operator>= (const An &lhs, const An &rhs)
An eu::lerp_angle (const An &from, float v, const An &to)
AA eu::rha (const n3 &axis, const An &angle)
std::string eu::string_from (const AA &aa)
std::string eu::string_from (const Ypr &ypr)
std::string eu::string_from (const m4 &m)
 Convert a matrix to a string representation, prefer fmt.
m4 eu::operator+ (const m4 &lhs, const m4 &rhs)
m4 eu::operator- (const m4 &lhs, const m4 &rhs)
m4 eu::operator* (const m4 &lhs, const m4 &rhs)
v4 eu::operator* (const m4 &lhs, const v4 &rhs)
constexpr bool eu::is_zero (float r, float epsilon=kk::epsilon)
constexpr bool eu::is_equal (float lhs, float rhs, float epsilon=kk::epsilon)
int eu::floor_to_int (float v)
int eu::ceil_to_int (float v)
constexpr int eu::get_sign (float r)
 Calculates the sign as a positive or a negative int.
constexpr float eu::get_sign (bool b)
 Returns 1 if true or -1.
constexpr float eu::lerp_float (float f, float scale, float t)
constexpr float eu::square (float r)
 Return r * r.
constexpr float eu::min (float lhs, float rhs)
constexpr float eu::max (float lhs, float rhs)
constexpr float eu::clamp_zero (float value, float def=0.0f, float epsilon=kk::epsilon)
 If the value is close to zero, def is returned.
constexpr float eu::keep_within01 (float f)
float eu::dot (const Q &lhs, const Q &rhs)
std::string eu::string_from (const Q &v)
 Converts a quaternion to string, prefer fmt.
Q eu::operator* (const Q &lhs, const Q &rhs)
Q eu::operator* (float scale, const Q &q)
Q eu::operator* (const Q &q, float scale)
template<typename T>
R< T > eu::make_range (T min, T max)
 Create a range from min to max (inclusive).
template<typename T>
R< T > eu::make_range (T max)
 Create a range from zero (0) to max (inclusive).
float eu::from_01f (float lower_bound, float upper_bound, float value)
template<typename T>
eu::from_01 (const R< T > &range, float value)
 Converts a value in 0-1 range to a custom range.
template<>
float eu::from_01 (const R< float > &range, float value)
template<typename T>
float eu::to01 (const R< T > &range, T value)
 Converts a value in a range to the 0-1 range.
template<typename T>
eu::get360_angular (const R< T > &range, float value)
template<typename T, typename F>
eu::remap_to (const R< F > &from, const R< T > &to, F value)
 Remaps a value from one range to another.
template<typename T>
bool eu::is_within (const R< T > &range, T value)
 Returns true if a value is withing a range.
template<typename T>
eu::keep_within (const R< T > &range, T value)
 Returns a value that is kept within the range.
template<typename T>
eu::wrap (const R< T > &range, T value)
 Returns a value that wraps around the range.
constexpr bool eu::operator== (const Size &lhs, const Size &rhs)
std::string eu::string_from (const Size &v)
 converts a 2d unit vector to a string, prefer fmt
v2 eu::operator+ (const v2 &lhs, const v2 &rhs)
v2 eu::operator- (const v2 &lhs, const v2 &rhs)
v2 eu::operator* (const v2 &lhs, float rhs)
v2 eu::operator* (const v2 &lhs, const v2 &rhs)
v2 eu::operator* (float lhs, const v2 &rhs)
v2 eu::operator* (const n2 &lhs, float rhs)
v2 eu::operator* (float lhs, const n2 &rhs)
v2 eu::operator/ (const v2 &lhs, float rhs)
float eu::dot (const v2 &lhs, const v2 &rhs)
v2 eu::lerp_vec2f (const v2 &from, float v, const v2 &to)
std::string eu::string_from (const v2 &v)
 converts a 2d vector to a string, prefer fmt
std::string eu::string_from (const n2 &v)
 converts a 2d unit vector to a string, prefer fmt
v3 eu::operator+ (const v3 &lhs, const v3 &rhs)
v3 eu::operator- (const v3 &lhs, const v3 &rhs)
v3 eu::operator* (float lhs, const v3 &rhs)
v3 eu::operator* (const v3 &lhs, float rhs)
v3 eu::operator/ (const v3 &lhs, float rhs)
v3 eu::operator/ (float lhs, const v3 &rhs)
v3 eu::lerp_v3 (const v3 &f, float v, const v3 &t)
std::string eu::string_from (const v3 &v)
 convert a 3d vector to string, prefer fmt
std::string eu::string_from (const n3 &v)
 converts a 3d unit vector to string, prefer fmt
constexpr v3 eu::min (const v3 &lhs, const v3 &rhs)
 component wise min value
constexpr v3 eu::max (const v3 &lhs, const v3 &rhs)
 component wise max value
std::string eu::string_from (const v4 &v)
 converts a 4d vector to a string, prefer fmt

Variables

constexpr An eu::one_turn = An::from_radians(pi * 2.0f)
constexpr An eu::half_turn = An::from_radians(pi)
constexpr An eu::quarter_turn = An::from_radians(pi / 2.0f)
constexpr An eu::no_rotation = An::from_radians(0.0f)
constexpr m4 eu::m4_identity = m4::from_scalar(1)
 The identity matrix.
constexpr Q eu::q_identity = Q(1, v3(0, 0, 0))
 The identity quaternion.
constexpr R< float > eu::r01 = { 0.0f, 1.0f}
 A range going from 0 to 1.
constexpr R< float > eu::r11 = { -1.0f, 1.0}
constexpr v2 eu::zero2f = v2{ 0, 0 }
constexpr v3 eu::zero3f = v3{0.0f, 0.0f, 0.0f}

Detailed Description

Function Documentation

◆ acos()

An eu::acos ( float v)

#include <angle.h>

◆ asin()

An eu::asin ( float v)

#include <angle.h>

◆ atan()

An eu::atan ( float v)

#include <angle.h>

◆ atan2()

An eu::atan2 ( float y,
float x )

#include <angle.h>

◆ ceil_to_int()

int eu::ceil_to_int ( float v)

#include <numeric.h>

◆ clamp_zero()

float eu::clamp_zero ( float value,
float def = 0.0f,
float epsilon = kk::epsilon )
constexpr

#include <numeric.h>

If the value is close to zero, def is returned.

Definition at line 84 of file numeric.h.

◆ cos()

float eu::cos ( const An & ang)

#include <angle.h>

◆ dot() [1/2]

float eu::dot ( const Q & lhs,
const Q & rhs )

#include <quat.h>

◆ dot() [2/2]

float eu::dot ( const v2 & lhs,
const v2 & rhs )

#include <vec2.h>

◆ floor_to_int()

int eu::floor_to_int ( float v)

#include <numeric.h>

◆ from_01() [1/2]

template<>
float eu::from_01 ( const R< float > & range,
float value )

#include <range.h>

◆ from_01() [2/2]

template<typename T>
T eu::from_01 ( const R< T > & range,
float value )

#include <range.h>

Converts a value in 0-1 range to a custom range.

Definition at line 61 of file range.h.

◆ from_01f()

float eu::from_01f ( float lower_bound,
float upper_bound,
float value )

#include <range.h>

◆ get360_angular()

template<typename T>
T eu::get360_angular ( const R< T > & range,
float value )

#include <range.h>

Definition at line 91 of file range.h.

◆ get_sign() [1/2]

float eu::get_sign ( bool b)
constexpr

#include <numeric.h>

Returns 1 if true or -1.

Definition at line 58 of file numeric.h.

◆ get_sign() [2/2]

int eu::get_sign ( float r)
constexpr

#include <numeric.h>

Calculates the sign as a positive or a negative int.

Returns
1 if r is greater than 0, -1 if not.

Definition at line 49 of file numeric.h.

◆ is_equal()

bool eu::is_equal ( float lhs,
float rhs,
float epsilon = kk::epsilon )
constexpr

#include <numeric.h>

Definition at line 33 of file numeric.h.

◆ is_within()

template<typename T>
bool eu::is_within ( const R< T > & range,
T value )

#include <range.h>

Returns true if a value is withing a range.

Definition at line 108 of file range.h.

◆ is_zero()

bool eu::is_zero ( float r,
float epsilon = kk::epsilon )
constexpr

#include <numeric.h>

Definition at line 27 of file numeric.h.

◆ keep_within()

template<typename T>
T eu::keep_within ( const R< T > & range,
T value )

#include <range.h>

Returns a value that is kept within the range.

i.e the value can't go lower than the lower bound or higher than the higher bound

See also
wrap

Definition at line 117 of file range.h.

◆ keep_within01()

float eu::keep_within01 ( float f)
constexpr

#include <numeric.h>

Definition at line 90 of file numeric.h.

◆ lerp_angle()

An eu::lerp_angle ( const An & from,
float v,
const An & to )

#include <angle.h>

◆ lerp_float()

float eu::lerp_float ( float f,
float scale,
float t )
constexpr

#include <numeric.h>

Definition at line 66 of file numeric.h.

◆ lerp_v3()

v3 eu::lerp_v3 ( const v3 & f,
float v,
const v3 & t )

#include <vec3.h>

◆ lerp_vec2f()

v2 eu::lerp_vec2f ( const v2 & from,
float v,
const v2 & to )

#include <vec2.h>

◆ make_range() [1/2]

template<typename T>
R< T > eu::make_range ( T max)

#include <range.h>

Create a range from zero (0) to max (inclusive).

Definition at line 46 of file range.h.

◆ make_range() [2/2]

template<typename T>
R< T > eu::make_range ( T min,
T max )

#include <range.h>

Create a range from min to max (inclusive).

Definition at line 39 of file range.h.

◆ max() [1/2]

v3 eu::max ( const v3 & lhs,
const v3 & rhs )
constexpr

#include <vec3.h>

component wise max value

Definition at line 166 of file vec3.h.

◆ max() [2/2]

float eu::max ( float lhs,
float rhs )
constexpr

#include <numeric.h>

Definition at line 79 of file numeric.h.

◆ min() [1/2]

v3 eu::min ( const v3 & lhs,
const v3 & rhs )
constexpr

#include <vec3.h>

component wise min value

Definition at line 155 of file vec3.h.

◆ min() [2/2]

float eu::min ( float lhs,
float rhs )
constexpr

#include <numeric.h>

Definition at line 78 of file numeric.h.

◆ operator*() [1/14]

An eu::operator* ( const An & lhs,
float rhs )

#include <angle.h>

◆ operator*() [2/14]

m4 eu::operator* ( const m4 & lhs,
const m4 & rhs )

#include <mat4.h>

◆ operator*() [3/14]

v4 eu::operator* ( const m4 & lhs,
const v4 & rhs )

#include <mat4.h>

◆ operator*() [4/14]

v2 eu::operator* ( const n2 & lhs,
float rhs )

#include <vec2.h>

◆ operator*() [5/14]

Q eu::operator* ( const Q & lhs,
const Q & rhs )

#include <quat.h>

◆ operator*() [6/14]

Q eu::operator* ( const Q & q,
float scale )

#include <quat.h>

◆ operator*() [7/14]

v2 eu::operator* ( const v2 & lhs,
const v2 & rhs )

#include <vec2.h>

◆ operator*() [8/14]

v2 eu::operator* ( const v2 & lhs,
float rhs )

#include <vec2.h>

◆ operator*() [9/14]

v3 eu::operator* ( const v3 & lhs,
float rhs )

#include <vec3.h>

◆ operator*() [10/14]

v2 eu::operator* ( float lhs,
const n2 & rhs )

#include <vec2.h>

◆ operator*() [11/14]

v2 eu::operator* ( float lhs,
const v2 & rhs )

#include <vec2.h>

◆ operator*() [12/14]

v3 eu::operator* ( float lhs,
const v3 & rhs )

#include <vec3.h>

◆ operator*() [13/14]

An eu::operator* ( float rhs,
const An & lhs )

#include <angle.h>

◆ operator*() [14/14]

Q eu::operator* ( float scale,
const Q & q )

#include <quat.h>

◆ operator+() [1/4]

An eu::operator+ ( const An & lhs,
const An & rhs )

#include <angle.h>

◆ operator+() [2/4]

m4 eu::operator+ ( const m4 & lhs,
const m4 & rhs )

#include <mat4.h>

◆ operator+() [3/4]

v2 eu::operator+ ( const v2 & lhs,
const v2 & rhs )

#include <vec2.h>

◆ operator+() [4/4]

v3 eu::operator+ ( const v3 & lhs,
const v3 & rhs )

#include <vec3.h>

◆ operator-() [1/4]

An eu::operator- ( const An & lhs,
const An & rhs )

#include <angle.h>

◆ operator-() [2/4]

m4 eu::operator- ( const m4 & lhs,
const m4 & rhs )

#include <mat4.h>

◆ operator-() [3/4]

v2 eu::operator- ( const v2 & lhs,
const v2 & rhs )

#include <vec2.h>

◆ operator-() [4/4]

v3 eu::operator- ( const v3 & lhs,
const v3 & rhs )

#include <vec3.h>

◆ operator/() [1/4]

An eu::operator/ ( const An & lhs,
float rhs )

#include <angle.h>

◆ operator/() [2/4]

v2 eu::operator/ ( const v2 & lhs,
float rhs )

#include <vec2.h>

◆ operator/() [3/4]

v3 eu::operator/ ( const v3 & lhs,
float rhs )

#include <vec3.h>

◆ operator/() [4/4]

v3 eu::operator/ ( float lhs,
const v3 & rhs )

#include <vec3.h>

◆ operator<()

bool eu::operator< ( const An & lhs,
const An & rhs )

#include <angle.h>

◆ operator<=()

bool eu::operator<= ( const An & lhs,
const An & rhs )

#include <angle.h>

◆ operator==()

bool eu::operator== ( const Size & lhs,
const Size & rhs )
constexpr

#include <size.h>

Definition at line 15 of file size.h.

◆ operator>()

bool eu::operator> ( const An & lhs,
const An & rhs )

#include <angle.h>

◆ operator>=()

bool eu::operator>= ( const An & lhs,
const An & rhs )

#include <angle.h>

◆ remap_to()

template<typename T, typename F>
T eu::remap_to ( const R< F > & from,
const R< T > & to,
F value )

#include <range.h>

Remaps a value from one range to another.

Definition at line 101 of file range.h.

◆ rha()

AA eu::rha ( const n3 & axis,
const An & angle )
nodiscard

#include <axisangle.h>

◆ sin()

float eu::sin ( const An & ang)

#include <angle.h>

◆ square()

float eu::square ( float r)
constexpr

#include <numeric.h>

Return r * r.

Definition at line 73 of file numeric.h.

◆ string_from() [1/11]

std::string eu::string_from ( const AA & aa)

#include <axisangle.h>

◆ string_from() [2/11]

std::string eu::string_from ( const An & a)

#include <angle.h>

◆ string_from() [3/11]

std::string eu::string_from ( const m4 & m)

#include <mat4.h>

Convert a matrix to a string representation, prefer fmt.

◆ string_from() [4/11]

std::string eu::string_from ( const n2 & v)

#include <vec2.h>

converts a 2d unit vector to a string, prefer fmt

◆ string_from() [5/11]

std::string eu::string_from ( const n3 & v)

#include <vec3.h>

converts a 3d unit vector to string, prefer fmt

◆ string_from() [6/11]

std::string eu::string_from ( const Q & v)

#include <quat.h>

Converts a quaternion to string, prefer fmt.

◆ string_from() [7/11]

std::string eu::string_from ( const Size & v)

#include <size.h>

converts a 2d unit vector to a string, prefer fmt

◆ string_from() [8/11]

std::string eu::string_from ( const v2 & v)

#include <vec2.h>

converts a 2d vector to a string, prefer fmt

◆ string_from() [9/11]

std::string eu::string_from ( const v3 & v)

#include <vec3.h>

convert a 3d vector to string, prefer fmt

◆ string_from() [10/11]

std::string eu::string_from ( const v4 & v)

#include <vec4.h>

converts a 4d vector to a string, prefer fmt

◆ string_from() [11/11]

std::string eu::string_from ( const Ypr & ypr)

#include <axisangle.h>

◆ tan()

float eu::tan ( const An & ang)

#include <angle.h>

◆ to01()

template<typename T>
float eu::to01 ( const R< T > & range,
T value )

#include <range.h>

Converts a value in a range to the 0-1 range.

Definition at line 83 of file range.h.

◆ wrap()

template<typename T>
T eu::wrap ( const R< T > & range,
T value )

#include <range.h>

Returns a value that wraps around the range.

When the value go outside the range, the value is wrapped back to either the start if exited at the end or vice versa.

Definition at line 134 of file range.h.

Variable Documentation

◆ half_turn

An eu::half_turn = An::from_radians(pi)
constexpr

#include <angle.h>

Definition at line 87 of file angle.h.

◆ m4_identity

m4 eu::m4_identity = m4::from_scalar(1)
constexpr

#include <mat4.h>

The identity matrix.

Definition at line 177 of file mat4.h.

◆ no_rotation

An eu::no_rotation = An::from_radians(0.0f)
constexpr

#include <angle.h>

Definition at line 89 of file angle.h.

◆ one_turn

An eu::one_turn = An::from_radians(pi * 2.0f)
constexpr

#include <angle.h>

Definition at line 86 of file angle.h.

◆ q_identity

Q eu::q_identity = Q(1, v3(0, 0, 0))
constexpr

#include <quat.h>

The identity quaternion.

Definition at line 130 of file quat.h.

◆ quarter_turn

An eu::quarter_turn = An::from_radians(pi / 2.0f)
constexpr

#include <angle.h>

Definition at line 88 of file angle.h.

◆ r01

R<float> eu::r01 = { 0.0f, 1.0f}
constexpr

#include <range.h>

A range going from 0 to 1.

Definition at line 52 of file range.h.

◆ r11

R<float> eu::r11 = { -1.0f, 1.0}
constexpr

#include <range.h>

Definition at line 55 of file range.h.

◆ zero2f

v2 eu::zero2f = v2{ 0, 0 }
constexpr

#include <vec2.h>

Definition at line 71 of file vec2.h.

◆ zero3f

v3 eu::zero3f = v3{0.0f, 0.0f, 0.0f}
constexpr

#include <vec3.h>

Definition at line 88 of file vec3.h.