Skip to content

Latest commit

 

History

History
387 lines (303 loc) · 23.9 KB

func_common.md

File metadata and controls

387 lines (303 loc) · 23.9 KB

func_common methods

The following methods are all part of the func_common methods.
It contains common GLSL functions.

Table of contents

abs() function

glm.abs(x: float) -> float

  Returns x if x >= 0; otherwise it returns -x.

glm.abs(x: vecN) -> vecN

  For each component c of x,
  Returns c if c >= 0; otherwise it returns -c.

ceil() function

glm.ceil(x: float) -> float

  Returns a value equal to the nearest integer that is greater than or equal to x.

glm.ceil(x: vecN) -> vecN

  For each component c of x,
  Returns a value equal to the nearest integer that is greater than or equal to c.

clamp() function

glm.clamp(x: number, minVal: number, maxVal: number) -> number

  Returns min(max(x, minVal), maxVal).

glm.clamp(x: vecN, minVal: number, maxVal: number) -> vecN

  Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values
  minVal and maxVal.

glm.clamp(x: vecN, minVal: vecN, maxVal: vecN) -> vecN

  Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values
  minVal and maxVal.

floatBitsToInt() function

glm.floatBitsToInt(v: float) -> int

  Returns a signed integer value representing the encoding of a floating-point value.
  The floating-point value's bit-level representation is preserved.

glm.floatBitsToInt(v: fvecN) -> ivecN

  Returns a signed integer value representing the encoding of a floating-point value.
  The floating-point value's bit-level representation is preserved.

floatBitsToUint() function

glm.floatBitsToUint(v: float) -> int

  Returns an unsigned integer value representing the encoding of a floating-point value.
  The floating-point value's bit-level representation is preserved.

glm.floatBitsToUint(v: fvecN) -> uvecN

  Returns an unsigned integer value representing the encoding of a floating-point value.
  The floating-point value's bit-level representation is preserved.

floor() function

glm.floor(x: float) -> float

  Returns a value equal to the nearest integer that is less then or equal to x.

glm.floor(v: vecN) -> vecN

  For each component c of v:
  Returns a value equal to the nearest integer that is less then or equal to c.

fma() function

glm.fma(a: float, b: float, c: float) -> float

  Computes and returns a * b + c.

fmax() function

glm.fmax(x: number, y: number) -> float

  Returns y if x < y; otherwise, it returns x. If one of the two arguments is NaN, the value
  of the other argument is returned.

glm.fmax(x: vecN, y: number) -> vecN

  For each component c of x:
  Returns y if c < y; otherwise, it returns c. If one of the two arguments is NaN, the value
  of the other argument is returned.

glm.fmax(x: vecN, y: vecN) -> vecN

  For every index i:
  Returns y[i] if x[i] < y[i]; otherwise, it returns x[i]. If one of the two arguments is
  NaN, the value of the other argument is returned.

glm.fmax(a: vecN, b: vecN, c: vecN) -> vecN

  Returns fmax(fmax(a, b), c).

glm.fmax(a: vecN, b: vecN, c: vecN, d: vecN) -> vecN

  Returns fmax(fmax(a, b), fmax(c, d)).

fmin() function

glm.fmin(x: number, y: number) -> float

  Returns y if y < x; otherwise, it returns x. If one of the two arguments is NaN, the value
  of the other argument is returned.

glm.fmin(x: vecN, y: number) -> vecN

  For each component c of x:
  Returns y if y < c; otherwise, it returns c. If one of the two arguments is NaN, the value
  of the other argument is returned.

glm.fmin(x: vecN, y: vecN) -> vecN

  For every index i:
  Returns y[i] if y[i] < x[i]; otherwise, it returns x[i]. If one of the two arguments is
  NaN, the value of the other argument is returned.

glm.fmin(a: vecN, b: vecN, **c **: vecN) -> vecN

  Returns fmin(fmin(a, b), c).

glm.fmin(a: vecN, b: vecN, **c **: vecN, d: vecN) -> vecN

  Returns fmin(fmin(a, b), fmin(c, d)).

fract() function

glm.fract(x: float) -> float

  Returns x - floor(x).

glm.fract(c: vecN) -> vecN

  Returns x - floor(x).

frexp() function

glm.frexp(x: float) -> (significant: float, exponent: int)

  Splits x into a floating-point significand in the range [0.5, 1.0) and an integral exponent
  of two, such that: x = significand * exp(2, exponent)

glm.frexp(x: vecN, exp: ivecN) -> vecN

  Splits x into a floating-point significand in the range [0.5, 1.0) and an integral exponent
  of two, such that: x = significand * exp(2, exponent)
  The significand is returned by the function and the exponent is returned in the parameter
  exp. For a floating-point value of zero, the significantand exponent are both zero. For a
  floating-point value that is an infinity or is not a number, the results are undefined.

intBitsToFloat() function

glm.intBitsToFloat(v: int) -> float

  Returns a floating-point value corresponding to a signed integer encoding of a floating-point
  value. If an inf or NaN is passed in, it will not signal, and the resulting floating point
  value is unspecified. Otherwise, the bit-level representation is preserved.

glm.intBitsToFloat(v: ivecN) -> fvecN

  Returns a floating-point value corresponding to a signed integer encoding of a floating-point
  value. If an inf or NaN is passed in, it will not signal, and the resulting floating point
  value is unspecified. Otherwise, the bit-level representation is preserved.

isinf() function

glm.isinf(x: float) -> bool

  Returns True if x holds a positive infinity or negative infinity representation in the
  underlying implementation's set of floating point representations.
  Returns False otherwise, including for implementations with no infinity representations.

glm.isinf(x: vecN) -> bvecN

  Returns True if x holds a positive infinity or negative infinity representation in the
  underlying implementation's set of floating point representations.
  Returns False otherwise, including for implementations with no infinity representations.

glm.isinf(x: quat) -> bvecN

  Returns True if x holds a positive infinity or negative infinity representation in the
  underlying implementation's set of floating point representations.
  Returns False otherwise, including for implementations with no infinity representations.

isnan() function

glm.isnan(x: float) -> bool

  Returns True if x holds a NaN (not a number) representation in the underlying
  implementation's set of floating point representations.
  Returns False otherwise, including for implementations with no NaN representations.

glm.isnan(x: vecN) -> bvecN

  Returns True if x holds a NaN (not a number) representation in the underlying
  implementation's set of floating point representations.
  Returns False otherwise, including for implementations with no NaN representations.

glm.isnan(x: quat) -> bvecN

  Returns True if x holds a NaN (not a number) representation in the underlying
  implementation's set of floating point representations.
  Returns False otherwise, including for implementations with no NaN representations.

ldexp() function

glm.ldexp(x: number, exp: int) -> float

  Builds a floating-point number from x and the corresponding integral exponent of two in
  exp, returning: significand * exp(2, exponent). If this product is too large to be
  represented in the floating-point type, the result is undefined.

glm.ldexp(x: vecN, exp: ivecN) -> vecN

  Builds a floating-point number from x and the corresponding integral exponent of two in
  exp, returning: significand * exp(2, exponent). If this product is too large to be
  represented in the floating-point type, the result is undefined.

max() function

glm.max(x: number, y: number) -> float

  Returns y if x < y; otherwise, it returns x.

glm.max(x: vecN, y: number) -> vecN

  Returns y if x < y; otherwise, it returns x.

glm.max(x: vecN, y: vecN) -> vecN

  Returns y if x < y; otherwise, it returns x.

glm.max(a: number, b: number, c: number) -> float

  Returns the maximum value of 3 inputs.

glm.max(a: vecN, b: vecN, c: vecN) -> vecN

  Returns the maximum component wise value of 3 inputs.

glm.max(a: number, b: number, c: number, d: number) -> float

  Returns the maximum value of 4 inputs.

glm.max(a: vecN, b: vecN, c: vecN, d: vecN) -> vecN

  Returns the maximum component wise value of 4 inputs.

glm.max(iterable) -> any

  Returns the greatest number or the maximum component wise value respectively.

min() function

glm.min(x: number, y: number) -> float

  Returns y if y < x; otherwise, it returns x.

glm.min(x: vecN, y: number) -> vecN

  Returns y if y < x; otherwise, it returns x.

glm.min(x: vecN, y: vecN) -> vecN

  Returns y if y < x; otherwise, it returns x.

glm.min(a: number, b: number, c: number) -> float

  Returns the minimum value of 3 inputs.

glm.min(a: vecN, b: vecN, c: vecN) -> vecN

  Returns the minimum component wise value of 3 inputs.

glm.min(a: number, b: number, c: number, d: number) -> float

  Returns the minimum value of 4 inputs.

glm.min(a: vecN, b: vecN, c: vecN, d: vecN) -> vecN

  Returns the minimum component wise value of 4 inputs.

glm.min(iterable) -> any

  Returns the smallest number or the minimum component wise value respectively.

mix() function

glm.mix(x: number, y: number, a: float) -> number

  Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point
  value a. The value for a is not restricted to the range [0, 1].

glm.mix(x: number, y: number, a: bool) -> number

  Returns y if a is True and x otherwise.

glm.mix(x: vecN, y: vecN, a: fvecN) -> vecN

  Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point
  value a. The value for a is not restricted to the range [0, 1].

glm.mix(x: vecN, y: vecN, a: bvecN) -> vecN

  For each component index i:
  Returns y[i] if a[i] is True and x[i] otherwise.

glm.mix(x: matNxM, y: matNxM, a: fmatNxM) -> matNxM

  Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point
  value a for each component. The value for a is not restricted to the range [0, 1].

glm.mix(x: matNxM, y: matNxM, a: float) -> matNxM

  Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point
  value a for each component. The value for a is not restricted to the range [0, 1].

glm.mix(x: quat, y: quat, a: float) -> quat

  Spherical linear interpolation of two quaternions. The interpolation is oriented and the
  rotation is performed at constant speed. For short path spherical linear interpolation, use
  the slerp function.

mod() function

glm.mod(a, b) -> Any

  Equivalent to a % b.

modf() function

glm.modf(x: float) -> (fraction, integer)

  Returns the fractional part of x and the integer part (as a whole number floating point value).

glm.modf(x: vecN, i: vecN) -> vecN

  Returns the fractional part of x and sets i to the integer part (as a whole number floating
  point value).

round() function

glm.round(x: number) -> float

  Returns a value equal to the nearest integer to x. The fraction 0.5 will round in a
  direction chosen by the implementation, presumably the direction that is fastest. This
  includes the possibility that round(x) returns the same value as roundEven(x)

glm.round(x: vecN) -> vecN

  Returns a value equal to the nearest integer to x. The fraction 0.5 will round in a
  direction chosen by the implementation, presumably the direction that is fastest. This
  includes the possibility that round(x) returns the same value as roundEven(x) for all
  values of x.

roundEven() function

glm.roundEven(x: number) -> float

  Returns a value equal to the nearest integer to x. A fractional part of 0.5 will round
  toward the nearest even integer. (Both 3.5 and 4.5 for x will return 4.0.)

glm.roundEven(x: vecN) -> vecN

  Returns a value equal to the nearest integer to x. A fractional part of 0.5 will round
  toward the nearest even integer. (Both 3.5 and 4.5 for x will return 4.0.)

sign() function

glm.sign(x: number) -> float

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

glm.sign(x: vecN) -> vecN

  For every component c of x:
  Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.

smoothstep() function

glm.smoothstep(edge0: number, edge1: number, x: number) -> float

  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. This is equivalent to :
  t = clamp((x - edge0) / (edge1 - edge0), 0, 1)
  return t * t * (3 - 2 * t)
  Results are undefined if edge0 >= edge1.

glm.smoothstep(edge0: number, edge1: number, x: vecN) -> vecN

  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. This is equivalent to :
  t = clamp((x - edge0) / (edge1 - edge0), 0, 1)
  return t * t * (3 - 2 * t)
  Results are undefined if edge0 >= edge1.

glm.smoothstep(edge0: vecN, edge1: vecN, x: vecN) -> vecN

  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. This is equivalent to :
  t = clamp((x - edge0) / (edge1 - edge0), 0, 1)
  return t * t * (3 - 2 * t)
  Results are undefined if edge0 >= edge1.

step() function

glm.step(edge: number, x: number) -> float

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

glm.step(edge: number, x: vecN) -> vecN

  For every component c of x:
  Returns 0.0 if c < edge, otherwise it returns 1.0.

glm.step(edge: vecN, x: vecN) -> vecN

  For every index i:
  Returns 0.0 if x[i] < edge[i], otherwise it returns 1.0.

trunc() function

glm.trunc(x: number) -> float

  Returns a value equal to the nearest integer to x whose absolute value is not larger than
  the absolute value of x.

glm.trunc(x: vecN) -> vecN

  For every component c of x:
  Returns a value equal to the nearest integer to c whose absolute value is not larger than
  the absolute value of c.

uintBitsToFloat() function

glm.uintBitsToFloat(v: int) -> float

  Returns a floating-point value corresponding to an unsigned integer encoding of a floating-point
  value. If an inf or NaN is passed in, it will not signal, and the resulting floating point
  value is unspecified. Otherwise, the bit-level representation is preserved.

glm.uintBitsToFloat(v: ivecN) -> fvecN

  Returns a floating-point value corresponding to an unsigned integer encoding of a floating-point
  value. If an inf or NaN is passed in, it will not signal, and the resulting floating point
  value is unspecified. Otherwise, the bit-level representation is preserved.