Synesthesia fun.syn.live
Contribute GitHub
← functions FUNCTION GLSL

rot

2D rotation matrix. Returns a mat2 so you can rotate a coordinate plane in place with p.xy *= rot(a), rather than transforming a point like _rotate does.

#math#rotation

Synesthesia already ships _rotate(uv, angle), which rotates a vec2 and hands it back. So why would you need rot()?

_rotate transforms a point, and often what you want is the matrix itself.

mat2 rot(float a) {
    float s = sin(a);
    float c = cos(a);
    return mat2(c, s, -s, c);
}
submitted by
@UFFFD
author
Unknown / community-sourced
source
Submitted directly
license
Unknown
Related · #math