gl3n.math

gl3n.math

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.

Public Imports

std.math
public import std.math : PI, sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, asinh, acosh, atanh, pow, exp, log, exp2, log2, sqrt, floor, trunc, round, ceil, modf;
std.algorithm
public import std.algorithm : min, max;

Members

Aliases

fract
alias fract = floor
Undocumented in source.
roundEven
alias roundEven = round
Undocumented in source.

Functions

abs
T abs(T t)

Calculates the absolute value.

abs
T abs(T vec)
T abs(T quat)

Calculates the absolute value per component.

almost_equal
bool almost_equal(T a, S b, float epsilon)

Compares to values and returns true if the difference is epsilon or smaller.

almost_equal
bool almost_equal(T a, T b, float epsilon)
Undocumented in source. Be warned that the author may not have intended to support it.
cdegrees
real cdegrees()

Compiletime version of degrees.

clamp
CommonType!(T1, T2, T3) clamp(T1 x, T2 min_val, T3 max_val)

Returns min(max(x, min_val), max_val), Results are undefined if min_val > max_val.

cradians
real cradians()

Compiletime version of radians.

degrees
real degrees(real radians)

Converts radians to degrees.

fmodf
float fmodf(float x, float y)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
inversesqrt
real inversesqrt(real x)

Returns 1/sqrt(x), results are undefined if x <= 0.

mod
T mod(T x, T y)

Modulus. Returns x - y * floor(x/y).

radians
real radians(real degrees)

Converts degrees to radians.

sign
float sign(T x)

Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.

smoothstep
CommonType!(T1, T2, T3) smoothstep(T1 edge0, T2 edge1, T3 x)

Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold function with a smooth transition.

step
float step(T1 edge, T2 x)

Returns 0.0 if x < edge, otherwise it returns 1.0.

Variables

PI_180
enum real PI_180;

PI / 180 at compiletime, used for degrees/radians conversion.

_180_PI
enum real _180_PI;

180 / PI at compiletime, used for degrees/radians conversion.

Meta

Authors

David Herberth

License

MIT