[英]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.