mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Add rotate function
This commit is contained in:
parent
7212a98d65
commit
131ecce7c4
1 changed files with 19 additions and 0 deletions
19
manimlib/shaders/inserts/rotate.glsl
Normal file
19
manimlib/shaders/inserts/rotate.glsl
Normal file
|
@ -0,0 +1,19 @@
|
|||
mat3 rotationMatrix(vec3 axis, float angle) {
|
||||
axis = normalize(axis);
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
float oc = 1.0 - c;
|
||||
float ax = axis.x;
|
||||
float ay = axis.y;
|
||||
float az = axis.z;
|
||||
|
||||
return mat3(
|
||||
oc * ax * ax + c, oc * ax * ay - az * s, oc * az * ax + ay * s,
|
||||
oc * ax * ay + az * s, oc * ay * ay + c, oc * ay * az - ax * s,
|
||||
oc * az * ax - ay * s, oc * ay * az + ax * s, oc * az * az + c
|
||||
);
|
||||
}
|
||||
|
||||
vec3 rotate(vec3 vect, float angle, vec3 axis){
|
||||
return rotationMatrix(axis, angle) * vect;
|
||||
}
|
Loading…
Add table
Reference in a new issue