1
votes

I have a 3d plane at the world origin that is aligned with the world X/Y plane (facing the Z axis). I then have four 3d vertex positions for a new plane transformed into some location in 3d space.

Both planes have the same winding order for all 4 vertices.

I have a guarantee that the 4 corners are planar and there is no skewing (the plane may have still been scaled individually on the x/y axes).

How can I create a 4x4 transformation matrix given the final 4 corners of this plane?

1
So the original plane is also defined by 4 corners? And are these also unskewed?meowgoesthedog
Yes, the original plane is always located at the origin (0,0,0), with corners at (-0.5, -0.5), (0.5, -0.5), (-0.5, 0.5), (0.5, 0.5) (on the world X/Y plane)user3209118
I'm voting to close this question as off-topic because it is about mathematics instead of programming / coding / programming tools / software algorithms.Pang

1 Answers

3
votes

Assume that the plane looks like this:

enter image description here

Construct a "local basis" of the plane, with the:

  • X-axis parallel to AD / BC
  • Y-axis parallel to AB / CD
  • Z-axis parallel to the normal
  • Origin O at the center of the quad

enter image description here

The transformation matrix can be decomposed into 3 components:


1 – Scale

Since the original quad has dimensions of 1x1 units, the scaling factor along the X and Y local axes are simply the side lengths, i.e. the lengths of AD and AB respectively. Ignore the Z scaling factor since the quad is planar.

Therefore the scaling component is given by:

enter image description here


2 - Rotation

The rotational component can be directly constructed from the local basis axes X, Y, Z; each vector (normalized) is the corresponding column of the matrix.

enter image description here

Therefore the rotational component is given by:

enter image description here


3 - Translation

This is the easiest one; the translation vector is simply the absolute coordinate of the quad's center O, and is equal to the last column of the matrix.

enter image description here

Therefore the translational component is given by:

enter image description here


The final matrix can be obtained by multiplying the above in the following order:

enter image description here

i.e. the components are applied in the order 123.