Given two points $P_0(x_0,y_0,z_0)$ and $P_1(x_1,y_1,z_1)$, and being $P_0$ the centroid of a square delimited by the following points: $$ (x_0 - 0.25, y_0 - 0.25, z_0) $$ $$ (x_0 + 0.25, y_0 - 0.25, z_0) $$ $$ (x_0 + 0.25, y_0 + 0.25, z_0) $$ $$ (x_0 - 0.25, y_0 + 0.25, z_0) $$ we know that vector $\vec{P_0P_1} = (x_1 - x_0, y_1 - y_0, z_1 - z_0)$ should be a normal of the previous plane. I would like to find the rotation matrix for the plane that solves the issue.
Find 3D rotation matrix for a plane, given surface normal and point lying on the plane
0
$\begingroup$
geometry
3d
rotations
plane-geometry
-
0Not exactly clear what you are asking. Do you want to tilt the square in such a way that it is perpendicular to $\vec{P_0 P_1}$? Or do you need to rotate $P_1$? – 2017-02-28
-
0@Andrei Exactly, that's the point (the first one), and $P_0$ must be the center of rotation. Sorry if I formulated the question in a bad way... – 2017-02-28
1 Answers
1
The normal to the original square is $\vec{n}=(0,0,1)$. To calculate the rotation of $\vec{n}$ onto $\vec{p}=\vec{P_0P_1}$, the axis of rotation is given by $\vec{p}\times\vec{n}$. Yo can calculate the angle from the dot product. You can get the rotation matrix using https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle If you want to rotate the square instead, it's the same rotation axis, with the opposite sign angle
-
0Sorry, one more question. Now I can rotate $\vec{n}$ to make $\vec{p}$ the new normal of my square, so the rotation matrix $R$ that I have calculated is right. Is it possible to use $R$ to calculate the new position of the four points delimiting the square, or do I need another method for that purpose? – 2017-03-01
-
0You can use $R$ for the square as well – 2017-03-01