0

我正在尝试围绕其中一个角旋转一个矩形,但我只能围绕中心进行。我将 Eigen 与 libigl 一起使用。我的代码:

// rectangle to rotate so as to be aligned to Y axis
MatrixXd V;

V.resize(24, 3);

V <<
-1.833111, -1.280510 , -0.000000,
2.124274 , -0.698183 , -0.000000,
-2.124274,  0.698183 ,  0.000000,
1.833111 ,  1.280510 ,  0.000000,
-1.978693,  -0.291164, -0.000000,
0.145582 ,  -0.989346, -0.000000,
1.978693 ,  0.291164 ,  0.000000,
-0.145582,  0.989346 ,  0.000000,
0.000000 ,  0.000000 ,  0.000000,
-1.905902,  -0.785837, -0.000000,
1.134928 ,  -0.843764, -0.000000,
1.905902 ,   0.785837,  0.000000,
-1.134928,   0.843764,  0.000000,
1.062137 ,  -0.349091, -0.000000,
-2.051483,   0.203510,  0.000000,
-0.843764,  -1.134928, -0.000000,
2.051483 ,  -0.203510, -0.000000,
0.843764 ,  1.134928 ,  0.000000,
-1.062137,  0.349091 ,  0.000000,
-0.072791,  0.494673 ,  0.000000,
0.989346 ,  0.145582 ,  0.000000,
0.916555 ,  0.640255 ,  0.000000,
-0.916555,  -0.640255, -0.000000,
0.072791 ,  -0.494673, -0.000000,
-0.989346,  -0.145582, -0.000000;

// right edge vector normalized (LSV) (with all combined edges summed)
Vector3d LSV;

LSV << 0.989346220797831, 0.145581782490286, 0;

axis = Vector3d::UnitY();

// calculate the rotation matrix so as to align the rectangle right edge to Y axis

Matrix3d RM;

RM = igl::rotation_matrix_from_directions(LSV, axis);

MatrixXd RV;

RV = V * RM;

V = RV;

igl::rotation_matrix_from_directions默认情况下围绕其中心旋转 V。现在,一旦我有了旋转矩阵 RM,我想对其进行变换,以便围绕右下角旋转矩形。可能吗?谢谢你。

4

0 回答 0