determinant
On this page

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
Matrix displayed by rows. Constructor arguments run down each column.
Result
determinant(M) = 24
Example 2M = diag(-1, 1, 1, 1)
-1000010000100001
Matrix displayed by rows. Constructor arguments run down each column.
Result
determinant(M) = -1
Example 3M = diag(1, 0, 1, 1)
1000000000100001
Matrix displayed by rows. Constructor arguments run down each column.
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.

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): number
declare function determinant(m: mat3x3): number
declare function determinant(m: mat4x4): number

A 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)

Examples

See also

Edit this page Report a problem