c++ - CGAL 在 3D 中按 x 轴旋转

标签 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> 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并使用 transformation matrix 指定变换矩阵.

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

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

关于c++ - CGAL 在 3D 中按 x 轴旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29370779/

相关文章:

python - 从二进制图像中提取形状/多边形?

algorithm - 由一组多边形将平面分割为非重叠区域

c++ - CGAL:手动创建用于形状检测的点集

c++ - 通过在 CGAL 中传递高度、宽度、深度和数据指针来创建 Image_3 实例

c++ - CGAL,限制在矩形中的裁剪 voronoi 图

c++ - protobuf 与 rapidjson 数据格式

c++ - 在 Linux 上 boost windows_shared_memory

C++简单加密

c++ - 错误 :expected unqualified-id before '=' token

algorithm - 如何从半边结构中去除边?