Re: [Algorithms] How to derive transformation matrices
Brought to you by:
vexxed72
|
From: <ro...@do...> - 2000-07-25 14:55:55
|
Robert Dibley wrote:
>I think most people in this case take shear to mean a transformation in
>which there is an invariant plane, but everything outside that plane is
>moved within its own parallel plane, so viewing through the said invariant
>plane, you would see this :
>
>
> pre-shear post-shear
>
> +------+ +------+
> | | / /
>--+------+----- -----+------+-------- invariant plane
> | | / /
> +------+ +------+
>
That's pretty close to the way a mathematician would define it, but
your statement needs a little sharpening and a nomenclature
adjustment. The sharpening: it's understood that "transformation"
implies "linear" of "affine", so that the displacements in all the
parallel planes are mutually parallel (or antiparallel) and are
proportional to the signed distance from the fixed plane. Your ASCII
art suggest the mutually parallel property but does not in fact imply
it in the 3D case, because the artwork lacks one dimension. Your art
does give a pretty solid indication of the displacement
proportionality property (at least in the font in which I am viewing
it), but again, art is not math.
The point of nomenclature: What you are calling the "invariant"
plane, would be called the "fixed plane" by most math authors. Each
point of the fixed plane is mapped to itself by the transformation, so
it consists entirely of fixed points of the mapping. Then each of
the planes parallel to it would be called "invariant" under the
transformation, because each is mapped to itself, that is each point
in such a plane is mapped to another point in the same plane..
OK, as promised, given the intrinsic definition I'll show you how to
get the matrix. Again, the matrix depends on the coordinate system.
It's straightforward to write down the matrix in the case that the
mapping is nicely aligned with the coordinate system, i.e the case
that the fixed plane is a coordinate plane and the mutually parallel
displacement direction is in the direction of one of the coordinate
axes in that plane. Just as Martin indicated, you write down the
linear equations that express what we have just described in words,
and pick off the coefficients to get the matrix. So it would be, for
the case that the fixed plane is the xy plane and the translation
direction is in the direction of the x axis
1 0 c
0 1 0
0 0 1
where c is a non-zero constant giving the amount of shear, the
proportionality constant relating the displacement in the invariant
plane to its z coordinate. A lot simpler than for the axis-aligned
rotation, isn't it?.
But of course, we want to be able to express the matrix in ANY
coordinate system, not just a system aligned with the intrinsic
parameters of the mapping. Just as with rotations, there are two
ways. The first, for which it is messy to write down a general
formula but not hard to derive in a particular case:
(1) Find a transformation T that maps the xy plane of the coordinate
system to the fixed plane of the shear and the x axis to the
displacement direction of the shear, try to make it simple, e.g. (a
rotation, if the origin is in the fixed plane, a rotation and
translation if it is not), and work out the similarity transformation
T^-1 S T, where S is the above matrix for the axis-aligned shear (or
its obvious extension to a 4x4).
The second, which I prefer because of its manifest coordinate
invariance
(2) Go back to the verbal description of the mapping and write it as a
vector geometric equation. Intrinsically, the shear mapping is
described by
a fixed plane, which is described by a point with position
vector P0 and a unit normal vector N,
a unit displacement vector U which is parallel to that plane,
so perpendicular to N,
and a scalar shear constant c, which gives the rate at which
the displacement grows as you move perpendicular to the fixed plane.
Let V be the position vector of any point. Writing down the vector
equation described by the above verbal description is fairly direct.
The result is that V is mapped to a point with position vector V'
given by
V' = V + c ((V - P0) dot N) U
Voila. A manifestly coordinate invariant vector expression for the
shear mapping. You get the 4x4 matrix with respect to ANY coordinate
system as follows. Express P0, N and U in their components with
respect to the given coordinate system. For the translation part of
the 4x4 matrix, substitute (0,0,0) for V. The resulting components of
V' = -c(P0 dot N)U give the first three elements of the last row or
column of the 4x4 affine matrix. For the upper left 3x3 linear part,
successively substitute the basis vectors (1,0,0), (0,1,0), (0,0,1)
for V. Then the rows or columns of the upper left 3x3 part are formed
by the respective resulting components of V'.
>Useful for certain effects, but in general not a good thing because unlike a
>rotation matrix it doesn't preserve your normals.
>
True. Also, the inverse is no longer the transpose (of the 3x3 linear
part), and other nice properties of orthogonal matrices are also lost.
But you can still recover the normal of a transformed surface by
applying the inverse of the transpose of the 3x3 linear part to the
corresponding normal of the untransformed surface.
|