Functions

Functions

GLM Core

The functions defined by the specification. More...

Functions

template<typename genType >
genType acos (genType const &x)
template<typename genType >
genType acosh (genType const &x)
template<typename genType >
genType asin (genType const &x)
template<typename genType >
genType asinh (genType const &x)
template<typename genType >
genType atan (genType const &y, genType const &x)
template<typename genType >
genType atan (genType const &y_over_x)
template<typename genType >
genType atanh (genType const &x)
template<typename T , template< typename > class C>
C< T >::signed_type bitCount (C< T > const &Value)
template<typename genIUType >
genIUType bitfieldExtract (genIUType const &Value, int const &Offset, int const &Bits)
template<typename genIUType >
genIUType bitfieldInsert (genIUType const &Base, genIUType const &Insert, int const &Offset, int const &Bits)
template<typename genIUType >
genIUType bitfieldReverse (genIUType const &value)
template<typename genType >
genType cos (genType const &angle)
template<typename genType >
genType cosh (genType const &angle)
template<typename T >
detail::tvec3< T > cross (detail::tvec3< T > const &x, detail::tvec3< T > const &y)
template<typename genType >
genType degrees (genType const &radians)
template<typename T >
detail::tmat2x2< T >::value_type determinant (detail::tmat2x2< T > const &m)
template<typename T >
detail::tmat3x3< T >::value_type determinant (detail::tmat3x3< T > const &m)
template<typename T >
detail::tmat4x4< T >::value_type determinant (detail::tmat4x4< T > const &m)
template<typename genType >
genType::value_type distance (genType const &p0, genType const &p1)
template<typename genType >
genType::value_type dot (genType const &x, genType const &y)
template<typename genType >
genType exp (genType const &x)
template<typename genType >
genType exp2 (genType const &x)
template<typename genType >
genType faceforward (genType const &N, genType const &I, genType const &Nref)
template<typename T , template< typename > class C>
C< T >::signed_type findLSB (C< T > const &Value)
template<typename T , template< typename > class C>
C< T >::signed_type findMSB (C< T > const &Value)
template<typename genIType >
void imulExtended (genIType const &x, genIType const &y, genIType &msb, genIType &lsb)
template<typename T >
detail::tmat2x2< T > inverse (detail::tmat2x2< T > const &m)
template<typename T >
detail::tmat3x3< T > inverse (detail::tmat3x3< T > const &m)
template<typename T >
detail::tmat4x4< T > inverse (detail::tmat4x4< T > const &m)
template<typename genType >
genType inversesqrt (genType const &x)
template<typename genType >
genType::value_type length (genType const &x)
template<typename genType >
genType log (genType const &x)
template<typename genType >
genType log2 (genType const &x)
template<typename matType >
matType matrixCompMult (matType const &x, matType const &y)
template<typename genType >
genType::value_type noise1 (genType const &x)
template<typename genType >
detail::tvec2< typename
genType::value_type > 
noise2 (genType const &x)
template<typename genType >
detail::tvec3< typename
genType::value_type > 
noise3 (genType const &x)
template<typename genType >
detail::tvec4< typename
genType::value_type > 
noise4 (genType const &x)
template<typename genType >
genType normalize (genType const &x)
template<typename vecType , typename matType >
matType outerProduct (vecType const &c, vecType const &r)
double packDouble2x32 (detail::tvec2< detail::uint32 > const &v)
detail::uint32 packSnorm4x8 (detail::tvec4< detail::float32 > const &v)
detail::uint32 packUnorm2x16 (detail::tvec2< detail::float32 > const &v)
detail::uint32 packUnorm4x8 (detail::tvec4< detail::float32 > const &v)
template<typename genType >
genType pow (genType const &x, genType const &y)
template<typename genType >
genType radians (genType const &degrees)
template<typename genType >
genType reflect (genType const &I, genType const &N)
template<typename genType >
genType refract (genType const &I, genType const &N, typename genType::value_type const &eta)
template<typename genType >
genType sin (genType const &angle)
template<typename genType >
genType sinh (genType const &angle)
template<typename genType >
genType sqrt (genType const &x)
template<typename genType >
genType tan (genType const &angle)
template<typename genType >
genType tanh (genType const &angle)
template<typename matType >
matType::transpose_type transpose (matType const &x)
template<typename genUType >
genUType uaddCarry (genUType const &x, genUType const &y, genUType &carry)
template<typename genUType >
void umulExtended (genUType const &x, genUType const &y, genUType &msb, genUType &lsb)
detail::tvec2< detail::uint32 > unpackDouble2x32 (double const &v)
detail::tvec4< detail::float32 > unpackSnorm4x8 (detail::uint32 const &p)
detail::tvec2< detail::float32 > unpackUnorm2x16 (detail::uint32 const &p)
detail::tvec4< detail::float32 > unpackUnorm4x8 (detail::uint32 const &p)
template<typename genUType >
genUType usubBorrow (genUType const &x, genUType const &y, genUType &borrow)

Detailed Description

The functions defined by the specification.

< Define all geometric functions from Section 8.4 of GLSL 1.30.8 specification. Included in glm namespace.


Function Documentation

genType glm::core::function::trigonometric::acos ( genType const &  x)

Arc cosine.

Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1.

genType glm::core::function::trigonometric::acosh ( genType const &  x)

Arc hyperbolic cosine; returns the non-negative inverse of cosh.

Results are undefined if x < 1.

genType glm::core::function::trigonometric::asin ( genType const &  x)

Arc sine.

Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1.

genType glm::core::function::trigonometric::asinh ( genType const &  x)

Arc hyperbolic sine; returns the inverse of sinh.

genType glm::core::function::trigonometric::atan ( genType const &  y,
genType const &  x 
)

Arc tangent.

Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0.

Referenced by glm::gtx::compatibility::atan2().

genType glm::core::function::trigonometric::atan ( genType const &  y_over_x)

Arc tangent.

Returns an angle whose tangent is y_over_x. The range of values returned by this function is [-PI/2, PI/2].

genType glm::core::function::trigonometric::atanh ( genType const &  x)

Arc hyperbolic tangent; returns the inverse of tanh.

Results are undefined if abs(x) >= 1.

C<T>::signed_type glm::core::function::integer::bitCount ( C< T > const &  Value)

Returns the number of bits set to 1 in the binary representation of value.

genIUType glm::core::function::integer::bitfieldExtract ( genIUType const &  Value,
int const &  Offset,
int const &  Bits 
)

Extracts bits [offset, offset + bits - 1] from value, returning them in the least significant bits of the result.

For unsigned data types, the most significant bits of the result will be set to zero. For signed data types, the most significant bits will be set to the value of bit offset + base – 1.

If bits is zero, the result will be zero. The result will be undefined if offset or bits is negative, or if the sum of offset and bits is greater than the number of bits used to store the operand.

genIUType glm::core::function::integer::bitfieldInsert ( genIUType const &  Base,
genIUType const &  Insert,
int const &  Offset,
int const &  Bits 
)

Returns the insertion the bits least-significant bits of insert into base.

The result will have bits [offset, offset + bits - 1] taken from bits [0, bits – 1] of insert, and all other bits taken directly from the corresponding bits of base. If bits is zero, the result will simply be base. The result will be undefined if offset or bits is negative, or if the sum of offset and bits is greater than the number of bits used to store the operand.

genIUType glm::core::function::integer::bitfieldReverse ( genIUType const &  value)

Returns the reversal of the bits of value.

The bit numbered n of the result will be taken from bit (bits - 1) - n of value, where bits is the total number of bits used to represent value.

genType glm::core::function::trigonometric::cos ( genType const &  angle)

The standard trigonometric cosine function.

The values returned by this function will range from [-1, 1].

genType glm::core::function::trigonometric::cosh ( genType const &  angle)

Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2.

detail::tvec3<T> glm::core::function::geometric::cross ( detail::tvec3< T > const &  x,
detail::tvec3< T > const &  y 
)

Returns the cross product of x and y.

genType glm::core::function::trigonometric::degrees ( genType const &  radians)

Converts radians to degrees and returns the result.

detail::tmat2x2<T>::value_type glm::core::function::matrix::determinant ( detail::tmat2x2< T > const &  m)

Return the determinant of a mat2 matrix.

detail::tmat3x3<T>::value_type glm::core::function::matrix::determinant ( detail::tmat3x3< T > const &  m)

Return the determinant of a mat3 matrix.

detail::tmat4x4<T>::value_type glm::core::function::matrix::determinant ( detail::tmat4x4< T > const &  m)

Return the determinant of a mat4 matrix.

genType::value_type glm::core::function::geometric::distance ( genType const &  p0,
genType const &  p1 
)

Returns the distance betwwen p0 and p1, i.e., length(p0 - p1).

genType::value_type glm::core::function::geometric::dot ( genType const &  x,
genType const &  y 
)

Returns the dot product of x and y, i.e., result = x * y.

genType glm::core::function::exponential::exp ( genType const &  x)

Returns the natural exponentiation of x, i.e., e^x.

genType glm::core::function::exponential::exp2 ( genType const &  x)

Returns 2 raised to the x power.

genType glm::core::function::geometric::faceforward ( genType const &  N,
genType const &  I,
genType const &  Nref 
)

If dot(Nref, I) < 0.0, return N, otherwise, return -N.

C<T>::signed_type glm::core::function::integer::findLSB ( C< T > const &  Value)

Returns the bit number of the least significant bit set to 1 in the binary representation of value.

If value is zero, -1 will be returned.

C<T>::signed_type glm::core::function::integer::findMSB ( C< T > const &  Value)

Returns the bit number of the most significant bit in the binary representation of value.

For positive integers, the result will be the bit number of the most significant bit set to 1. For negative integers, the result will be the bit number of the most significant bit set to 0. For a value of zero or negative one, -1 will be returned.

void glm::core::function::integer::imulExtended ( genIType const &  x,
genIType const &  y,
genIType &  msb,
genIType &  lsb 
)

Multiplies 32-bit integers x and y, producing a 64-bit result.

The 32 least-significant bits are returned in lsb. The 32 most-significant bits are returned in msb.

detail::tmat2x2<T> glm::core::function::matrix::inverse ( detail::tmat2x2< T > const &  m)

Return the inverse of a mat2 matrix.

detail::tmat3x3<T> glm::core::function::matrix::inverse ( detail::tmat3x3< T > const &  m)

Return the inverse of a mat3 matrix.

detail::tmat4x4<T> glm::core::function::matrix::inverse ( detail::tmat4x4< T > const &  m)

Return the inverse of a mat4 matrix.

genType glm::core::function::exponential::inversesqrt ( genType const &  x)

Returns the reciprocal of the positive square root of x.

genType::value_type glm::core::function::geometric::length ( genType const &  x)

Returns the length of x, i.e., sqrt(x * x).

genType glm::core::function::exponential::log ( genType const &  x)

Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation x = e^y.

Results are undefined if x <= 0.

genType glm::core::function::exponential::log2 ( genType const &  x)

Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y.

matType glm::core::function::matrix::matrixCompMult ( matType const &  x,
matType const &  y 
)

Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product of x[i][j] and y[i][j].

genType::value_type glm::core::function::noise::noise1 ( genType const &  x)

Returns a 1D noise value based on the input value x.

detail::tvec2<typename genType::value_type> glm::core::function::noise::noise2 ( genType const &  x)

Returns a 2D noise value based on the input value x.

detail::tvec3<typename genType::value_type> glm::core::function::noise::noise3 ( genType const &  x)

Returns a 3D noise value based on the input value x.

detail::tvec4<typename genType::value_type> glm::core::function::noise::noise4 ( genType const &  x)

Returns a 4D noise value based on the input value x.

genType glm::core::function::geometric::normalize ( genType const &  x)

Returns a vector in the same direction as x but with length of 1.

matType glm::core::function::matrix::outerProduct ( vecType const &  c,
vecType const &  r 
)

Treats the first parameter c as a column vector and the second parameter r as a row vector and does a linear algebraic matrix multiply c * r.

double glm::core::function::packing::packDouble2x32 ( detail::tvec2< detail::uint32 > const &  v)

Returns a double-precision value obtained by packing the components of v into a 64-bit value.

If an IEEE 754 Inf or NaN is created, it will not signal, and the resulting floating point value is unspecified. Otherwise, the bit- level representation of v is preserved. The first vector component specifies the 32 least significant bits; the second component specifies the 32 most significant bits.

detail::uint32 glm::core::function::packing::packSnorm4x8 ( detail::tvec4< detail::float32 > const &  v)

First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.

Then, the results are packed into the returned 32-bit unsigned integer.

The conversion for component c of v to fixed point is done as follows: packSnorm4x8: round(clamp(c, -1, +1) * 127.0)

The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.

detail::uint32 glm::core::function::packing::packUnorm2x16 ( detail::tvec2< detail::float32 > const &  v)

First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.

Then, the results are packed into the returned 32-bit unsigned integer.

The conversion for component c of v to fixed point is done as follows: packUnorm2x16: round(clamp(c, 0, +1) * 65535.0)

The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.

detail::uint32 glm::core::function::packing::packUnorm4x8 ( detail::tvec4< detail::float32 > const &  v)

First, converts each component of the normalized floating-point value v into 8- or 16-bit integer values.

Then, the results are packed into the returned 32-bit unsigned integer.

The conversion for component c of v to fixed point is done as follows: packUnorm4x8: round(clamp(c, 0, +1) * 255.0)

The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.

genType glm::core::function::exponential::pow ( genType const &  x,
genType const &  y 
)

Returns x raised to the y power.

genType glm::core::function::trigonometric::radians ( genType const &  degrees)

Converts degrees to radians and returns the result.

genType glm::core::function::geometric::reflect ( genType const &  I,
genType const &  N 
)

For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N.

genType glm::core::function::geometric::refract ( genType const &  I,
genType const &  N,
typename genType::value_type const &  eta 
)

For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector.

genType glm::core::function::trigonometric::sin ( genType const &  angle)

The standard trigonometric sine function.

The values returned by this function will range from [-1, 1].

genType glm::core::function::trigonometric::sinh ( genType const &  angle)

Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2.

genType glm::core::function::exponential::sqrt ( genType const &  x)

Returns the positive square root of x.

genType glm::core::function::trigonometric::tan ( genType const &  angle)

The standard trigonometric tangent function.

genType glm::core::function::trigonometric::tanh ( genType const &  angle)

Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)

matType::transpose_type glm::core::function::matrix::transpose ( matType const &  x)

Returns the transposed matrix of x.

genUType glm::core::function::integer::uaddCarry ( genUType const &  x,
genUType const &  y,
genUType &  carry 
)

Adds 32-bit unsigned integer x and y, returning the sum modulo pow(2, 32).

The value carry is set to 0 if the sum was less than pow(2, 32), or to 1 otherwise.

void glm::core::function::integer::umulExtended ( genUType const &  x,
genUType const &  y,
genUType &  msb,
genUType &  lsb 
)

Multiplies 32-bit integers x and y, producing a 64-bit result.

The 32 least-significant bits are returned in lsb. The 32 most-significant bits are returned in msb.

detail::tvec2<detail::uint32> glm::core::function::packing::unpackDouble2x32 ( double const &  v)

Returns a two-component unsigned integer vector representation of v.

The bit-level representation of v is preserved. The first component of the vector contains the 32 least significant bits of the double; the second component consists the 32 most significant bits.

detail::tvec4<detail::float32> glm::core::function::packing::unpackSnorm4x8 ( detail::uint32 const &  p)

First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.

Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.

The conversion for unpacked fixed-point value f to floating point is done as follows: unpackSnorm4x8: clamp(f / 127.0, -1, +1)

The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.

detail::tvec2<detail::float32> glm::core::function::packing::unpackUnorm2x16 ( detail::uint32 const &  p)

First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.

Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.

The conversion for unpacked fixed-point value f to floating point is done as follows: unpackUnorm2x16: f / 65535.0

The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.

detail::tvec4<detail::float32> glm::core::function::packing::unpackUnorm4x8 ( detail::uint32 const &  p)

First, unpacks a single 32-bit unsigned integer p into a pair of 16-bit unsigned integers, four 8-bit unsigned integers, or four 8-bit signed integers.

Then, each component is converted to a normalized floating-point value to generate the returned two- or four-component vector.

The conversion for unpacked fixed-point value f to floating point is done as follows: unpackUnorm4x8: f / 255.0

The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.

genUType glm::core::function::integer::usubBorrow ( genUType const &  x,
genUType const &  y,
genUType &  borrow 
)

Subtracts the 32-bit unsigned integer y from x, returning the difference if non-negative, or pow(2, 32) plus the difference otherwise.

The value borrow is set to 0 if x >= y, or to 1 otherwise.