Created
February 18, 2018 00:24
-
-
Save cabbibo/2fecccb5092c44ef1aab2632f73a24da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float4x4 rotateX(float angle){ | |
angle = -angle/180.0*3.1415926536; | |
float c = cos(angle); | |
float s = sin(angle); | |
return float4x4(1.0, 0.0, 0.0, 0.0, 0.0, c, -s, 0.0, 0.0, s, c, 0.0, 0.0, 0.0, 0.0, 1.0); | |
} | |
float4x4 rotateY(float angle){ | |
angle = -angle/180.0*3.1415926536; | |
float c = cos(angle); | |
float s = sin(angle); | |
return float4x4(c, 0.0, s, 0.0, 0.0, 1.0, 0.0, 0.0, -s, 0.0, c, 0.0, 0.0, 0.0, 0.0, 1.0); | |
} | |
float4x4 rotateZ(float angle){ | |
angle = -angle/180.0*3.1415926536; | |
float c = cos(angle); | |
float s = sin(angle); | |
return float4x4(c, -s, 0.0, 0.0, s, c, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0); | |
} | |
float4x4 translate(float3 t){ | |
return float4x4(1.0, 0.0, 0.0, -t.x, 0.0, 1.0, 0.0, -t.y, 0.0, 0.0, 1.0, -t.z, 0.0, 0.0, 0.0, 1.0); | |
} | |
float4x4 rotationMat( in float3 xyz ) | |
{ | |
float3 si = sin(xyz); | |
float3 co = cos(xyz); | |
return float4x4( co.y*co.z, co.y*si.z, -si.y, 0.0, | |
si.x*si.y*co.z-co.x*si.z, si.x*si.y*si.z+co.x*co.z, si.x*co.y, 0.0, | |
co.x*si.y*co.z+si.x*si.z, co.x*si.y*si.z-si.x*co.z, co.x*co.y, 0.0, | |
0.0, 0.0, 0.0, 1.0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment