Created
June 15, 2020 13:51
-
-
Save hiroakioishi/f0806bf647efbadf71a93a4f2848475f to your computer and use it in GitHub Desktop.
オイラー角(ラジアン)を回転行列に変換
This file contains hidden or 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 eulerAnglesToRotationMatrix(float3 angles) | |
| { | |
| float ch = cos(angles.y); float sh = sin(angles.y); // heading | |
| float ca = cos(angles.z); float sa = sin(angles.z); // attitude | |
| float cb = cos(angles.x); float sb = sin(angles.x); // bank | |
| // Ry-Rx-Rz (Yaw Pitch Roll) | |
| return float4x4( | |
| ch * ca + sh * sb * sa, -ch * sa + sh * sb * ca, sh * cb, 0, | |
| cb * sa, cb * ca, -sb, 0, | |
| -sh * ca + ch * sb * sa, sh * sa + ch * sb * ca, ch * cb, 0, | |
| 0, 0, 0, 1 | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment