# 绕任意轴旋转的推导

   1: Transform Rotate(float angle, const Vector &axis) {
   2:     Vector a = Normalize(axis);
   3:     float s = sinf(Radians(angle));
   4:     float c = cosf(Radians(angle));
   5:     float m[4][4];
   6:
   7:     m[0][0] = a.x * a.x + (1.f - a.x * a.x) * c;
   8:     m[0][1] = a.x * a.y * (1.f - c) - a.z * s;
   9:     m[0][2] = a.x * a.z * (1.f - c) + a.y * s;
  10:     m[0][3] = 0;
  11:
  12:     m[1][0] = a.x * a.y * (1.f - c) + a.z * s;
  13:     m[1][1] = a.y * a.y + (1.f - a.y * a.y) * c;
  14:     m[1][2] = a.y * a.z * (1.f - c) - a.x * s;
  15:     m[1][3] = 0;
  16:
  17:     m[2][0] = a.x * a.z * (1.f - c) - a.y * s;
  18:     m[2][1] = a.y * a.z * (1.f - c) + a.x * s;
  19:     m[2][2] = a.z * a.z + (1.f - a.z * a.z) * c;
  20:     m[2][3] = 0;
  21:
  22:     m[3][0] = 0;
  23:     m[3][1] = 0;
  24:     m[3][2] = 0;
  25:     m[3][3] = 1;
  26:
  27:     Matrix4x4 mat(m);
  28:     return Transform(mat, Transpose(mat));
  29: }
• 本文已收录于以下专栏：

举报原因： 您举报文章：绕任意轴旋转的推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)