【问题标题】:CGAL rotation by x-axis in 3DCGAL 在 3D 中按 x 轴旋转
【发布时间】:2015-03-31 14:16:20
【问题描述】:

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

【问题讨论】:

    标签: c++ computational-geometry cgal


    【解决方案1】:

    要在 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
    

    【讨论】:

      猜你喜欢
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 2012-06-30
      • 1970-01-01
      相关资源
      最近更新 更多