繁体   English   中英

3D中x轴的CGAL旋转

[英]CGAL rotation by x-axis in 3D

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);
}

要进行3D旋转,可以使用Aff_transformation_3并使用变换矩阵指定变换矩阵

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM