sKit  0.0.9
sKit::math Namespace Reference

Functions for math. More...

Functions

auto map (float value, float inputMin, float inputMax, float outputMin, float outputMax, bool clamp=true) -> float
 Given a value and an input range, map the value to an output range. More...
 
auto flatten (const glm::mat4 &mat) -> std::array< float, 16 >
 flattens a 4x4 matrix with row major order More...
 

Detailed Description

Functions for math.

Function Documentation

◆ flatten()

auto sKit::math::flatten ( const glm::mat4 &  mat) -> std::array< float, 16 >

flattens a 4x4 matrix with row major order

Definition at line 42 of file math.cpp.

◆ map()

auto sKit::math::map ( float  value,
float  inputMin,
float  inputMax,
float  outputMin,
float  outputMax,
bool  clamp = true 
) -> float

Given a value and an input range, map the value to an output range.

map linearly maps the given value to a new value given an input and output range. Thus if value is 50% of the way between inputMin and inputMax, the output value will be 50% of the way between outpuMin and outputMax. For an input value outside of the intputMin and inputMax range, negative percentages and percentages greater than 100% will be used. For example, if the input value is 150 and the input range is 0 - 100 and the output range 0 - 1000, the output value will be 1500 or 150% of the total range. The user can avoid mapping outside of the input range by clamping the output value. Clamping is disabled by default and ensures that the output value always stays in the range [outputMin, outputMax).

Example:

float x = 5;
float newx = 0;
// 0 <= x < 10
newx = sKit::math::map(x, 0, 10, 21, 22);

Source: https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/math/ofMath.cpp#L63C1-L85C2

Parameters
valueThe number to be mapped.
inputMinThe lower bound of the input range.
inputMaxThe upper bound of the input range.
outputMinThe lower bound of the output range.
outputMaxThe upper bound of the output range.
clampTrue if the value should be clamped to [outputMin, outputMax).
Note
If the absolute difference between inputMin and inputMax is less than std::numeric_limits<float>::epsilon(), outputMin will be returned to prevent divide by zero errors.
Returns
a mapped floating point number.
Examples
sKit_Example_Shapes.cpp.

Definition at line 10 of file math.cpp.

Referenced by sKit::geom::arc(), and sKit::geom::vertex::arc().

sKit::math::map
auto map(float value, float inputMin, float inputMax, float outputMin, float outputMax, bool clamp) -> float
Given a value and an input range, map the value to an output range.
Definition: math.cpp:10