Change rotation matrix of a rectangle from center to corner

294 views Asked by At

I'm trying to rotate a rectangle around one of its corners, but I'm only able to do it around the center. I'm using Eigen together with libigl. My code:

// 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 rotates V around its centre by default. Now, once I have the rotation matrix RM, I'd like to transform it so as to rotate the rectangle around the bottom right corner. Is it possible? Thank you.

0

There are 0 answers