You mean the rotation of the part itself? Rotations of 3D objects can be described as 3 different vectors which describe a space relative to those vectors. In this case we want a set of orthonormal vectors, vectors that are unit length and all perpendicular to each other, so that we can create a rotation matrix. Rotation matrices are what CFrames are made of. For this we want a “front” vector, “right” vector, and “up” vector to describe the 3 axis that make up our space. In 3D we can use the cross product between two vectors to give us a third vector that is perpendicular to both, so we only really need 2 vectors, or 3 points to calculate it. If you know which point you want to be in front left, which point you want to be on the back right, and which point you want to be on the back left, then calculating these vectors is easy:
front = (frontLeft - backLeft).unit
right = (backRight - backLeft).unit
up = right:Cross(front)
From here you can construct a CFrame using these vectors with the constructor that takes 12 numbers:
result = CFrame.new( x, y, z, right.x, up.x, -front.x, right.y, up.y, -front.y, right.z, up.z, -front.z )
Additionally, the position or center of the space can be described using 0.25 * (pos1 + pos2 + pos3 + pos4) assuming those 4 points describe a rectangle. Or you can just use the midpoint of two of the corners with: 0.5 * (corner + oppositeCorner). Both of those formulas use barycentric coordinates, and it won’t give you a perfect center for all point configurations, but it is guaranteed to give a point somewhere in the middle.
If you want a representation of it in Euler angles or axis angles, you can use pitch, yaw, roll = result:toEulerAnglesXYZ()
or axis, angle = result:toAxisAngle()
.
I skipped over quite a few details about why this works, but you can learn this in linear algebra.