Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/math_base_inline.c
| Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| MINLINE double ratiod(double min, double max, double pos) | MINLINE double ratiod(double min, double max, double pos) | ||||
| { | { | ||||
| double range = max - min; | double range = max - min; | ||||
| return range == 0 ? 0 : ((pos - min) / range); | return range == 0 ? 0 : ((pos - min) / range); | ||||
| } | } | ||||
| /* Map a normalized value, i.e. from interval [0, 1] to interval [a, b] */ | |||||
| MINLINE float scalenorm(float a, float b, float x) | |||||
| { | |||||
| BLI_assert(x <= 1 && x >= 0); | |||||
| return (x * (b - a)) + a; | |||||
| } | |||||
| /* used for zoom values*/ | /* used for zoom values*/ | ||||
| MINLINE float power_of_2(float val) | MINLINE float power_of_2(float val) | ||||
| { | { | ||||
| return (float)pow(2.0, ceil(log((double)val) / M_LN2)); | return (float)pow(2.0, ceil(log((double)val) / M_LN2)); | ||||
| } | } | ||||
| MINLINE int is_power_of_2_i(int n) | MINLINE int is_power_of_2_i(int n) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 626 Lines • Show Last 20 Lines | |||||