Let's consider the basic 3D coordinate system. I have a plane P defined with three points A(xa,ya,za), B(xb,yb,zb) and C(xc,yc,zc). I have some object (a mesh - set of vertices and triangles) in the coordinate system and the plane P is actually a cutting plane, which should split the mesh in two slices.
I will need to transform the mesh (to rotate it) relative to a fixed cutting plane (for example, plane z = 0 is the best fit - I need all values for z value to be equal, in order to do the cutting).
So as a first step in my algorithm, what I will need to do, is to transform (with transformation matrix R) the plane P to the plane z = 0, to use this plane as a reference for cutting the mesh and then to apply the reverse transformation matrix R' so that the mesh slices are transformed backed at their original locations.
My question now is: is it possible to calculate the transformation matrices R and R', based on the three points A, B, C on the plane P?
My guess is that I can do the following (calculate the normal vector by using the points A, B, C):
diffVectorBA = B - A = (xb-xa, yb-ya, zb-za);
diffVectorCA = C - A = (xc-xa, yc-ya, zc-za);
vectorNormal = crossProduct(diffVectorBA, diffVectorCA)
= (diffVectorBA.Y * diffVectorCA.Z - diffVectorBA.Z * diffVectorCA.Y,
diffVectorBA.Z * diffVectorCA.X - diffVectorBA.X * diffVectorCA.Z,
diffVectorBA.X * diffVectorCA.Y - diffVectorBA.Y * diffVectorCA.X);
but after calculating this, I'm not sure how to proceed and how to calculate R and R'?