# Plane equation to transformation matrix

## Recommended Posts

KommuSoft    100
Hi,

I have the following problem:

I have a plane equation described by Ax+By+Cz=0. I would like to draw a part of this plane in OpenGL, but don't know how to convert A, B and C intro a transformationmatrix.

The original plane before multiplication is simply a quad (square) defined by the following points: (-1,0,-1), (1,0,-1), (1,0,1), (-1,0,1). Because D=0 there is no translation, so the middle of the plane should stay at (0,0,0).

A brief mathematical explanation would be fine.

thanks.

##### Share on other sites
RetLee    124
I believe in order to define a plane you must have a constant d
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]Ax+By+Cz + d = 0[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]Work from there.[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[size="2"][color="#1c2837"]
[/color][/size]

##### Share on other sites
haegarr    7372
A plane given in Hessian form
[b]p[/b] . [b]n[/b] - d == 0
is infinite. It does have a normal defining its orientation and a distance from the origin of the reference co-ordinate system to the closest point of all points of the space that together build up the plane, but it does not have a (clear) tangent, bi-tangent, or origin (those values are more or less arbitrary). This is opposed to another representation form of a plane
[b]O[/b] + u * [b]t[/b] + v * [b]b[/b], u[sub]1[/sub] <= u <= u[sub]2[/sub], v[sub]1[/sub] <= v <= v[sub]2[/sub]
so that, assuming the typical |[b]t[/b]| = |[b]b[/b]| = 1 and [b]t[/b] . [b]b[/b] == 0,
[b]t[/b] x [b]b[/b] =: [b]n[/b]
[b]O[/b] . [b]n[/b] =: d

Hence asking for a transformation that maps the given quad onto the plane gives ambiguous results.

You can pick any point [b]p[/b] that fulfills
[b]p[/b] . [b]n[/b] - d == 0
as the translation part of the transformation. Perhaps you want to use the point closest to the origin for that purpose, then
[b]p[/b] := d * [b]n[/b]

Next, choose any (unit length) vector that is perpendicular to [b]n[/b] to get, say, the tangent [b]t[/b]. It looks like
[b]t[/b] . [b]n[/b] = 0
You'll notice that there is an infinite amount of possibilities, as already mentioned above.

Then utilize [b]t[/b] x [b]b[/b] =: [b]n[/b] to get the bi-tangent, i.e.
[b]b[/b] = -[b]t[/b] x [b]n[/b]

Next compose all these into a transformation matrix, e.g. for column vectors with the translation as 4th component. The quad in the OP has a normal in direction of the principal y axis that should be mapped to [b]n[/b], and lets use the x direction for [b]t[/b] and hence the -z direction for [b]b[/b]. So I'd expect something like
[ [b]t[/b] [b]n[/b] -[b][b]b[/b] p[/b] ]

I'm not sure whether or not [b]b[/b] need to be negated at last. Please double check this stuff.