zoukankan      html  css  js  c++  java
  • 旋转变换,对某个点进行绕x,y,z的变换。

    简介

    旋转变换,对某个点进行绕x,y,z的变换。

    代码

    #include <iostream>
    #include <vector>
    #include <algorithm>
    // -------------------- OpenMesh
    using namespace std;
    #define PI 3.1415926
    
    
    static void MatVec3(const double m[9], const double x[3], double y[3]) {//3*3 * 3*1 的矩阵
    	y[0] = m[0] * x[0] + m[1] * x[1] + m[2] * x[2];
    	y[1] = m[3] * x[0] + m[4] * x[1] + m[5] * x[2];
    	y[2] = m[6] * x[0] + m[7] * x[1] + m[8] * x[2];
    }
    
    //旋转一定的角度  in 输入点  out 变换输出点
    void Transform_Cloth_RotBryantAngle(double angle_x, double angle_y, double angle_z, const double  in[], double out[]) {
    	angle_x *= PI / 180.0;
    	angle_y *= PI / 180.0;
    	angle_z *= PI / 180.0;
    
    	const double Rx[9] = {
    		1,         0,          0,
    		0, cos(angle_x),-sin(angle_x),
    		0, sin(angle_x),cos(angle_x)
    	};
    	const double Ry[9] = {
    		cos(angle_y),       0, sin(angle_y),
    		0           ,       1,            0,
    		-sin(angle_y),       0, cos(angle_y)
    	};
    	const double Rz[9] = {
    		 cos(angle_z), -sin(angle_z),      0,
    		 sin(angle_z), cos(angle_z),      0,
    		            0,            0,      1 
    	};
    	double res[3] = { 0 };
    	MatVec3(Rx, in, out);
    	res[0] = out[0], res[1] = out[1], res[2] = out[2];
    	MatVec3(Ry, res, out);
    	res[0] = out[0], res[1] = out[1], res[2] = out[2];
    	MatVec3(Rz, res, out);
    	return;
    }
    
    int main()
    {
    	double point[3] = {1, 0, 0};
    	double out[3] = { 0 };
    	Transform_Cloth_RotBryantAngle(90,90,90,point, out);
    
    	cout << "POINT " << out[0] << " " << out[1] << " " << out[2] << std::endl;
    	system("pause");
    }
    
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    Linux之基础系统优化
    Linux之shell命令
    Django解决跨域问题
    Django中使用geetest验证
    python2与python3的区别
    一个长得很丑的登录和注册
    Django组件-forms组件
    Django组件-中间件
    cookie、session与用户认证组件
    jquery练习
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/11164370.html
Copyright © 2011-2022 走看看