绕任意轴旋转的推导

1287人阅读 评论(0)

   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: }
0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：6894056次
• 积分：82786
• 等级：
• 排名：第17名
• 原创：71篇
• 转载：4341篇
• 译文：2篇
• 评论：857条
公告
声明：早期转载的文章未标明转载敬请原谅，以后将陆续改过来，向原创者致敬！

文章分类