Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 三维中x轴的CGAL旋转_C++_Computational Geometry_Cgal - Fatal编程技术网

C++ 三维中x轴的CGAL旋转

C++ 三维中x轴的CGAL旋转,c++,computational-geometry,cgal,C++,Computational Geometry,Cgal,在CGAL中是否有预定义的x轴旋转。若否,原因为何?如果我必须定义它,我会怎么做 #include <CGAL/Simple_cartesian.h> #include <CGAL/Aff_transformation_3.h> #include <cmath> typedef CGAL::Simple_cartesian<double> Kernel; typedef CGAL::Aff_transformation_3<Kernel>

在CGAL中是否有预定义的x轴旋转。若否,原因为何?如果我必须定义它,我会怎么做

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Aff_transformation_3.h>
#include <cmath>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Aff_transformation_3<Kernel> transform3D;

transform3D rotationX(double angle)
{
    const double cosa{cos(angle)};
    const double sina{sin(angle)};
    return transform3D(
            1.0, 0.0, 0.0,
            0.0, cosa, -sina,
            0.0, sina, cosa);
}

void test()
{
    using Point3D = CGAL::Point_3<Kernel>;
    Point3D p{1.0,1.0,1.0};
    const transform3D rotate{rotationX(M_PI_2)};
    rotate(p);
}
#包括
#包括
#包括
简单笛卡尔核;
typedef CGAL::Aff_transformation_3 transform3D;
transform3D旋转X(双角度)
{
常数双余弦{cos(角)};
常数双sina{sin(角)};
返回转换3D(
1.0, 0.0, 0.0,
0.0,cosa,-新浪,
0.0、新浪、cosa);
}
无效测试()
{
使用Point3D=CGAL::Point_3;
Point3D p{1.0,1.0,1.0};
const transform3D rotate{rotationX(M_PI_2)};
旋转(p);
}

要在3D中旋转,可以使用并指定变换矩阵

例如:要在x轴上旋转一定角度x,可以使用如下矩阵:

1   0        0         0
0   cos(x)   -sin(x)   0
0   sin(x)   cos(x)    0
0   0        0         1