9

I have a set of points (x1, x2,..xn) that lie on the plane define by Ax+ By+Cz+d=0. I would like to find the transformation matrix to translate and rotate to XY plane. So, the new point coordinate will be x1'=(xnew, ynew,0).

A lot of answer give quaternion, dot or cross product matrix. I am not sure which one is the correct way.

Thank you

1
  • 1
    It seems to me like there's no single transformation matrix — you've no idea about rotation around the surface normal (A, B, C). If your surface were a post-it on a pin (with the pin being the surface normal) and I rotated the post-it without moving the pin, that wouldn't be recorded. So are you just looking for any transform that preserves distances and angles? Or e.g. have you a specific pair of points that you know are both on the x axis?
    – Tommy
    Jun 7, 2011 at 11:48

1 Answer 1

8

First of all, unless in your plane equation, d=0, there is no linear transformation you can apply. You need to instead perform an affine transformation.

One way to do this is to determine an angle and vector about which to rotate to make your pointset lie in a plane parallel to the XY plane (ie. the Z component of your transformed pointset to all have the same values). Then you simply drop the Z component.

For this, let V be the normalized plane normal for the plane containing your points. For convenience define from your plane equation above Ax+By+Cz+d=0:

V = (A, B, C)
V' = V / ||V|| = (A', B', C')
Z = (0, 0, 1)

where

A' = A / ||V||
B' = B / ||V||
C' = C / ||V||
||V|| = (A2+B2+C2)1/2

The angle will simply be:

θ = cos-1(ZV / ||V||)
  = cos-1(ZV')
  = cos-1(C')

The axis R about which to rotate is just the cross product of the normalized plane normal V' and Z. That is

R = V'×Z
  = (B', -A', 0)

You can now use this angle / axis pair to build the quaternion rotation needed to rotate all of the points in your dataset to a plane parallel to the XY plane. Then, a I said earlier, just drop the Z component to perform an orthogonal projection onto the XY plane.

Update: antonakos makes a good point about normalizing the R before using an API taking axis / angle pairs.

1
  • 1
    A sign issue: R = V' × Z, not R = Z × V'. Also it might be worth noting that many axis/angle APIs require R to be normalized (which it isn't yet).
    – antonakos
    Jun 7, 2011 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.