Re: Math/Theory Questions about PostScript-style drawing
Re: Math/Theory Questions about PostScript-style drawing
- Subject: Re: Math/Theory Questions about PostScript-style drawing
- From: "David W. Halliday" <email@hidden>
- Date: Mon, 17 Sep 2001 16:44:57 -0500
- Organization: Latin AmeriCom, formerly Latino Online
Matthew Cox wrote:
>
Anyone competent to respond to this message probably knows all this
>
intro, but I'm including it in case my comprehension is in someway
>
flawed.
>
>
I know that the 2D Transformation Matrix functions as, in poor notation:
>
>
[ a | b | u ]
>
[ c | d | v ]
>
[ tX| tY| w ]
>
>
And to calculate the position of a point (x', y') from an older point
>
(x, y):
>
>
x' = ax + cy + tX;
>
y' = bx + dy + tY;
>
>
And you create transformations based on the identity matrix:
>
>
[ 1 | 0 | 0 ]
>
[ 0 | 1 | 0 ]
>
[ 0 | 0 | 1 ]
>
>
And one can:
>
Translate:
>
[ 1 | 0 | 0 ]
>
[ 0 | 1 | 0 ]
>
[ bx|by | 1 ]
You're translating the /position/ of the point. (Of course, you knew
that. :-))
>
Scale:
>
[ Sx| 0 | 0 ]
>
[ 0 | Sy| 0 ]
>
[ 0 | 0 | 1 ]
You're scaling the /position/ of the point (relative to the origin).
>
And rotate:
>
[ cos(C) | sin(C) | 0 ]
>
[ -sin(C)| -cos(C)| 0 ]
>
[ 0 | 0 | 1 ]
You're rotating the /position/ of the point (about the origin).
>
So my question is: since these seem to operate on points individually,
>
how can multiplying a point by the scaling matrix enlarge it? It would
>
simply spit out a new point, and the same sort of idea for Rotation, is
>
it not just rotating a point, which is essentially a zero-dimensional
>
object? Or am I missing a portion of the step? For instance, wouldn't
>
the rotation matrix need to "know" what the center of rotation is? Or
>
would the scale need to know where to find the center of the construct,
>
so it could "stretch" points accordingly? I'm interested more in the
>
mathematics of it than the actual implementation and use, but still
>
real-world usage would be appreciated.
The transformations are all carried out on the coordinates of each and
every point. Therefore, if you wish to rotate an object, for instance,
around some particular point (in the object, such as it's "center", for
instance) then you create a transformation matrix that translates the origin
to the desired point, rotates about that origin, and then translates back to
the initial origin.
Of course, this can all be reduced to a single transformation matrix.
I hope this clears such things up. (Incidentally, this is far more
general than PostScript-style drawing---it is a general method for handling
the group of all linear transformations, including translation, allowed in 2
dimensional space, and can be easily generalized to higher dimensions.)
David email@hidden