determinant
Function
A determinant is the signed volume scale of a square linear transformation. A zero determinant means the transformation collapses a dimension.
Compare examples
Compare expansion, reflection, and a collapsed axis. Their determinants have different magnitudes or signs.
Example 1M = diag(2, 3, 4, 1)
2000030000400001 - Result
determinant(M) = 24
Example 2M = diag(-1, 1, 1, 1)
-1000010000100001 - Result
determinant(M) = -1
Example 3M = diag(1, 0, 1, 1)
1000000000100001 - Result
determinant(M) = 0
The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.
When to use it
Use it to detect a singular transform or an orientation reversal.
Inputs and limits
Only square matrices have a determinant. A value close to zero can make inversion numerically unstable.
For shader input rules and precision, consult WGSL and GLSL ES 3.00.
Related functions
- WGSL
determinant(a)- GLSL ES 3.00
determinant(a)
The signature, the sentence and any message are the compiler's own text at commit af54ddad5.
Returns the determinant of a mat4 as an f32.
Syntax
declare function determinant(m: mat2x2): numberdeclare function determinant(m: mat3x3): numberdeclare function determinant(m: mat4x4): numberA number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.
type f32 = number & { readonly [f32Tag]?: true }
A number you write as a type is inferred from its uses, and f32, i32 and u32 fix a width; the TypeScript constructs page carries that row with the compiler's emit.
Parameters
Return value
number
Targets
- WGSL
-
determinant(a) - GLSL ES 3.00
-
determinant(a)