1
\$\begingroup\$

I have 4 points as Vector3 in 3D space that shape a plane. How can I calculate the plane normal direction these four points create together, and express it as a Quaternion?

Guide Image

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

First, we'll average together the vertical and horizontal edges of your quad to get two vectors, pointing in the directions of the x and y axes of the transform gizmo in your diagram:

var x = C - A + D - B;
var y = C - D + A - B;

The z direction is then

var z = Vector3.Cross(x, y);

We can turn this into a quaternion using:

var planeOrientation = Quaternion.LookRotation(z, y);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .