Euphoria
Namespaces | Classes | Functions | Variables
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::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.
 
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< Teu::make_range (T min, T max)
 Create a range from min to max (inclusive)
 
template<typename T >
R< Teu::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 >
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 >
T eu::get360_angular (const R< T > &range, float value)
 
template<typename T , typename F >
T 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 >
T eu::keep_within (const R< T > &range, T value)
 Returns a value that is kept within the range.
 
template<typename T >
T eu::wrap (const R< T > &range, T value)
 Returns a value that wraps around the range.
 
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* (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< floateu::r01 = { 0.0f, 1.0f}
 A range going from 0 to 1.
 
constexpr R< floateu::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)

◆ asin()

An eu::asin ( float  v)

◆ atan()

An eu::atan ( float  v)

◆ atan2()

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

◆ ceil_to_int()

int eu::ceil_to_int ( float  v)

◆ clamp_zero()

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

#include <libs/base/src/base/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)

◆ dot() [1/2]

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

◆ dot() [2/2]

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

◆ floor_to_int()

int eu::floor_to_int ( float  v)

◆ from_01() [1/2]

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

◆ from_01() [2/2]

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

#include <libs/base/src/base/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 
)

◆ get360_angular()

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

#include <libs/base/src/base/range.h>

Definition at line 91 of file range.h.

◆ get_sign() [1/2]

constexpr float eu::get_sign ( bool  b)
constexpr

#include <libs/base/src/base/numeric.h>

Returns 1 if true or -1.

Definition at line 58 of file numeric.h.

◆ get_sign() [2/2]

constexpr int eu::get_sign ( float  r)
constexpr

#include <libs/base/src/base/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()

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

#include <libs/base/src/base/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 <libs/base/src/base/range.h>

Returns true if a value is withing a range.

Definition at line 108 of file range.h.

◆ is_zero()

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

#include <libs/base/src/base/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 <libs/base/src/base/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.

◆ lerp_angle()

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

◆ lerp_float()

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

#include <libs/base/src/base/numeric.h>

Definition at line 66 of file numeric.h.

◆ lerp_v3()

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

◆ lerp_vec2f()

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

◆ make_range() [1/2]

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

#include <libs/base/src/base/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 <libs/base/src/base/range.h>

Create a range from min to max (inclusive)

Definition at line 39 of file range.h.

◆ max() [1/2]

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

#include <libs/base/src/base/vec3.h>

component wise max value

Definition at line 164 of file vec3.h.

◆ max() [2/2]

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

#include <libs/base/src/base/numeric.h>

Definition at line 79 of file numeric.h.

◆ min() [1/2]

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

#include <libs/base/src/base/vec3.h>

component wise min value

Definition at line 153 of file vec3.h.

◆ min() [2/2]

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

#include <libs/base/src/base/numeric.h>

Definition at line 78 of file numeric.h.

◆ operator*() [1/13]

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

◆ operator*() [2/13]

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

◆ operator*() [3/13]

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

◆ operator*() [4/13]

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

◆ operator*() [5/13]

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

◆ operator*() [6/13]

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

◆ operator*() [7/13]

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

◆ operator*() [8/13]

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

◆ operator*() [9/13]

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

◆ operator*() [10/13]

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

◆ operator*() [11/13]

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

◆ operator*() [12/13]

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

◆ operator*() [13/13]

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

◆ operator+() [1/4]

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

◆ operator+() [2/4]

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

◆ operator+() [3/4]

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

◆ operator+() [4/4]

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

◆ operator-() [1/4]

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

◆ operator-() [2/4]

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

◆ operator-() [3/4]

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

◆ operator-() [4/4]

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

◆ operator/() [1/4]

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

◆ operator/() [2/4]

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

◆ operator/() [3/4]

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

◆ operator/() [4/4]

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

◆ operator<()

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

◆ operator<=()

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

◆ operator>()

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

◆ operator>=()

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

◆ remap_to()

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

#include <libs/base/src/base/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 
)

◆ sin()

float eu::sin ( const An ang)

◆ square()

constexpr float eu::square ( float  r)
constexpr

#include <libs/base/src/base/numeric.h>

Return r * r

Definition at line 73 of file numeric.h.

◆ string_from() [1/10]

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

◆ string_from() [2/10]

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

◆ string_from() [3/10]

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

#include <libs/base/src/base/mat4.h>

Convert a matrix to a string representation, prefer fmt.

◆ string_from() [4/10]

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

#include <libs/base/src/base/vec2.h>

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

◆ string_from() [5/10]

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

#include <libs/base/src/base/vec3.h>

converts a 3d unit vector to string, prefer fmt

◆ string_from() [6/10]

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

#include <libs/base/src/base/quat.h>

Converts a quaternion to string, prefer fmt.

◆ string_from() [7/10]

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

#include <libs/base/src/base/vec2.h>

converts a 2d vector to a string, prefer fmt

◆ string_from() [8/10]

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

#include <libs/base/src/base/vec3.h>

convert a 3d vector to string, prefer fmt

◆ string_from() [9/10]

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

#include <libs/base/src/base/vec4.h>

converts a 4d vector to a string, prefer fmt

◆ string_from() [10/10]

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

◆ tan()

float eu::tan ( const An ang)

◆ to01()

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

#include <libs/base/src/base/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 <libs/base/src/base/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

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

#include <libs/base/src/base/angle.h>

Definition at line 87 of file angle.h.

◆ m4_identity

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

#include <libs/base/src/base/mat4.h>

The identity matrix.

Definition at line 174 of file mat4.h.

◆ no_rotation

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

#include <libs/base/src/base/angle.h>

Definition at line 89 of file angle.h.

◆ one_turn

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

#include <libs/base/src/base/angle.h>

Definition at line 86 of file angle.h.

◆ q_identity

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

#include <libs/base/src/base/quat.h>

The identity quaternion.

Definition at line 121 of file quat.h.

◆ quarter_turn

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

#include <libs/base/src/base/angle.h>

Definition at line 88 of file angle.h.

◆ r01

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

#include <libs/base/src/base/range.h>

A range going from 0 to 1.

Definition at line 52 of file range.h.

◆ r11

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

#include <libs/base/src/base/range.h>

Definition at line 55 of file range.h.

◆ zero2f

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

#include <libs/base/src/base/vec2.h>

Definition at line 70 of file vec2.h.

◆ zero3f

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

#include <libs/base/src/base/vec3.h>

Definition at line 86 of file vec3.h.