旋转变换,对某个点进行绕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");
}

转载于:https://www.cnblogs.com/eat-too-much/p/11164370.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值