gl3n.math
gl3n.math
Discussion
Provides nearly all GLSL functions, according to spec 4.1,
it also publically imports other useful functions (from std.math, core.stdc.math, std.alogrithm)
so you only have to import this file to get all mathematical functions you need.
Publically imports: PI, sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh,
asinh, acosh, atanh, pow, exp, log, exp2, log2, sqrt, abs, floor, trunc, round, ceil, modf,
fmodf, min, max.
License
MIT
-
Declaration
enum realPI_180;PI / 180 at compiletime, used for degrees/radians conversion.
-
Declaration
enum real_180_PI;180 / PI at compiletime, used for degrees/radians conversion.
-
Declaration
Tmod(T)(Tx, Ty);Modulus. Returns
x-y* floor(x/y). -
Declaration
Tabs(T)(Tt) if (!is_vector!T && !is_quaternion!T && !is_matrix!T);Calculates the absolute value.
-
Declaration
Tabs(T)(Tvec) if (is_vector!T);
Tabs(T)(Tquat) if (is_quaternion!T);Calculates the absolute value per component.
-
Declaration
pure nothrow @safe realinversesqrt(realx);Returns 1/sqrt(
x), results are undefined ifx<= 0. -
Declaration
floatsign(T)(Tx);Returns 1.0 if
x> 0, 0.0 ifx= 0, or -1.0 ifx< 0. -
Declaration
boolalmost_equal(T, S)(Ta, Sb, floatepsilon= 1e-06F) if (!is_vector!T && !is_quaternion!T);
boolalmost_equal(T, S)(Ta, Sb, floatepsilon= 1e-06F) if (is_vector!T && is_vector!S && (T.dimension == S.dimension));Compares to values and returns
trueif the difference isepsilonor smaller. -
Declaration
pure nothrow @safe realradians(realdegrees);Converts
degreestoradians. -
Declaration
realcradians(real degrees)();Compiletime version of radians.
-
Declaration
pure nothrow @safe realdegrees(realradians);Converts
radianstodegrees. -
Declaration
realcdegrees(real radians)();Compiletime version of degrees.
-
Declaration
CommonType!(T1, T2, T3)clamp(T1, T2, T3)(T1x, T2min_val, T3max_val);Returns min(max(
x,min_val),max_val), Results are undefined ifmin_val>max_val. -
Declaration
floatstep(T1, T2)(T1edge, T2x);Returns 0.0 if
x<edge, otherwise it returns 1.0. -
Declaration
CommonType!(T1, T2, T3)smoothstep(T1, T2, T3)(T1edge0, T2edge1, T3x);Returns 0.0 if
x<=edge0and 1.0 ifx>=edge1and performs smooth hermite interpolation between 0 and 1 whenedge0<x<edge1. This is useful in cases where you would want a threshold function with a smooth transition.