# hdu 2898 旋转 三维空间一点绕一轴旋转后坐标 几何

#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cmath>
using namespace std;
float aa[4],bb[4];
float theta;
float  c;
float  s;
void Rotate_Point3D(float theta, float nx, float ny, float nz, float *aa, float *bb)
{
float len = sqrtf(nx * nx + ny * ny + nz * nz); //单位化
nx /= len;
ny /= len;
nz /= len;
bb[0] = aa[0] * (nx * nx *(1-c)+ c)          +aa[1] *  (nx * ny * (1 - c)- nz * s)  +  aa[2] * (nx * nz * (1 - c) + ny * s);
bb[1] = aa[0] * (nx * ny * (1 - c) + nz * s)  +aa[1] * (ny * ny * (1 - c) + c)        +  aa[2] * (ny * nz * (1 - c) - nx * s);
bb[2] = aa[0] * (nx * nz * (1 - c) - ny * s) +aa[1] * (ny * nz * (1 -c) + nx *s)      +  aa[2] * (nz * nz * (1 - c) + c);
}
int main()
{
float nx,ny,nz;
while(cin>>aa[0]>>aa[1]>>aa[2])
{
cin>>nx>>ny>>nz;
cin>>theta;
c=cosf(theta);
s=sinf(theta);
Rotate_Point3D(theta,nx,ny,nz,aa,bb);
cout<<setiosflags(ios::fixed)<<setprecision(3)<<bb[0]<<' '<<bb[1]<<' '<<bb[2]<<endl;
}

}

• 本文已收录于以下专栏：

举报原因： 您举报文章：hdu 2898 旋转 三维空间一点绕一轴旋转后坐标 几何 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)