Lets say I have a triangle defined by 3 vertices and a center point, how do I rotate the triangle so its normal is looking at a specified point?
Given points A, B and C of a triangle, the normal of the triangle is the cross product AB×AC (or possibly AC×AB depending on the vertex order). If the point on the triangle is M and the point towards which to look is P, you then have an infinite number of rotations that cause AB×AC to be in the direction of MP. The shortest rotation of them all can be computed using a quaternion from two vectors method. The final tranformation is therefore:
- subtract M from all triangle points so that the triangle centre is at the origin
- rotate all points using the quaternion described above
- re-add M to all triangle points
tranform = translate(OM) * rotate(quaternion(cross(AB,AC), MP) * translate(MO)