Skip to content

Commit

Permalink
feat: add mat2RotateDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston committed Jul 29, 2020
1 parent 80517a6 commit b2761ae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/shaders/includes/math/mat2.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ mat2 mat2Identity() {
return mat2( 1., 0., 0., 1. );
}

// https://thebookofshaders.com/08/
mat2 mat2RotateDirection( vec2 dir ){
return mat2( dir.x, -dir.y, dir.y, dir.x );
}

// validated - this is the same as the TS makeMatrix3RotationFromAngle
mat2 mat2Rotate(float angle){
float c = cos(angle);
float s = sin(angle);
return mat2RotateDirection( vec2( cos(angle), sin(angle) ) );
}

return mat2( c, -s, s, c );
// validated - this is the same as the TS makeMatrix3Scale
mat2 mat2Scale(vec2 scale){
return mat2( scale.x, 0., scale.y, 0 );
}

0 comments on commit b2761ae

Please sign in to comment.