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
  • 相关阅读:
    IOS Xcode编译项目-报错“ld: library not found for -XX”
    ios中关键词weak,assign,copy.strong等的区别
    iOS 控件
    iOS图片处理
    iOS 音频
    C语言文件操作
    iOS 删除相册中照片--来自简书
    ios sourecTree
    ios音频处理
    编码格式简介
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/11164370.html
Copyright © 2011-2022 走看看