三维坐标点绕任意轴旋转的新坐标计算
2013-08-03 17:37
337 查看
/article/8748294.html
任意轴可以用一个起点一个方向向量来表示。那么绕任意轴旋转就可以先将此轴移到通过原点,然后再旋转,再将旋转完的新坐标做反向平移。
则问题化为 计算绕通过原点的向量旋转任意角度后的新点。假设单位向量为(rx,ry,rz),那么旋转矩阵如下:
写成函数如下:
注意 单位向量、逆时针
任意轴可以用一个起点一个方向向量来表示。那么绕任意轴旋转就可以先将此轴移到通过原点,然后再旋转,再将旋转完的新坐标做反向平移。
则问题化为 计算绕通过原点的向量旋转任意角度后的新点。假设单位向量为(rx,ry,rz),那么旋转矩阵如下:
写成函数如下:
void Rotate_Point3D(float theta, float nx, float ny, float nz, float (&ptIn)[3], float (&ptOut)[3]) { float len = sqrtf(nx * nx + ny * ny + nz * nz); //单位化 nx /= len; ny /= len; nz /= len; ptOut[0] = ptIn[0] * (cosf(theta) + nx * nx * (1 - cosf(theta))) + //transform by matrix ptIn[1] * (nx * ny * (1 - cosf(theta)) - nz * sinf(theta)) + ptIn[2] * (nx * nz * (1 - cosf(theta) + ny * sinf(theta))); ptOut[1] = ptIn[0] * (nx * ny * (1 - cosf(theta)) + nz * sinf(theta)) + ptIn[1] * (ny * ny * (1 - cosf(theta)) + cosf(theta)) + ptIn[2] * (ny * nz * (1 - cosf(theta)) - nx * sinf(theta)); ptOut[2] = ptIn[0] * (nx * nz * (1 - cosf(theta) - ny * sinf(theta))) + ptIn[1] * (ny * nz * (1 -cosf(theta)) + nx * sinf(theta)) + ptIn[2] * (nz * nz * (1 - cosf(theta)) + cosf(theta)); }
注意 单位向量、逆时针
相关文章推荐
- 三维坐标点绕任意轴旋转的新坐标计算
- 三维旋转矩阵(包括任意轴的通用旋转矩阵、Euler角、单位四元数)的计算
- HDU 4449 Building Design 第37届ACM/ICPC 金华赛区H题 (计算几何,三维凸包+空间坐标旋转+二维凸包)
- 利用四元树来计算一个坐标点绕任意轴旋转后,新坐标点的推导过程
- openGL三维网格坐标,旋转,缩放,灯光设置,纹理读取,模型读取(MFC单文档)
- 传入一个圆心和任意一个点 计算相对旋转的角度
- 实现 计算两个三维坐标点的 距离
- 计算一点绕另一点旋转n度后的坐标
- 三维世界里的坐标和变换,逆方向旋转移动三维世界的方式来实现3D漫游
- 计算一点绕另一点旋转n度后的坐标
- 在平面中,一个点绕任意点旋转θ度后的点的坐标
- 三维坐标向任意平面的正平行投影
- 一个坐标点围绕任意中心点旋转--C#实现
- 积分计算两条曲线围绕y坐标轴旋转形成的立体体积
- 点的三维旋转坐标及在屏幕上的坐标
- 同一坐标系中,由任意两点计算地图旋转角度
- opencv 图像仿射变换 计算仿射变换后对应特征点的新坐标 图像旋转、缩放、平移
- ArcBall坐标旋转三维物体原理
- 关于解决这个问题:从一个点(x,y)绕另一个点(x0,y0)旋转任意角度A后得到的坐标(x1,y1)的坐标是多少?