Skip to content

Instantly share code, notes, and snippets.

@hiroakioishi
Created June 15, 2020 13:51
Show Gist options
  • Select an option

  • Save hiroakioishi/f0806bf647efbadf71a93a4f2848475f to your computer and use it in GitHub Desktop.

Select an option

Save hiroakioishi/f0806bf647efbadf71a93a4f2848475f to your computer and use it in GitHub Desktop.
オイラー角(ラジアン)を回転行列に変換
// オイラー角(ラジアン)を回転行列に変換
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