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: "Erik M. Buck" <email@hidden>
- Date: Mon, 17 Sep 2001 17:36:12 -0500
>
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
I can't give a proper textbook answer in brief, but I will try to answer
your basic misconception.
The traditional 2D affine matrix that you describe is a math
notation/shortcut used to define a "coordinate system" relative to an
"identity coordinate system". Given an arbitrarty transform matrix A, and a
point P, when you transform point P by matrix A, you are calculating the
equivelent point P1 in the "identity" coordinate system. Point P and Point
P1 are the _same_ point represented in different coordinate systems. Point
P is in the coordinate system defined by matrix A. Point P1 is in the
coordinate system defined by the "identity" matrix.
Points are not "enlarged". Points occupy no space so "enlarge" makes no
sense. A transformation matrix (A) that includes scaling just redifines the
conversion factor/scale of one unit distance in (A) vs. one unit distance in
the "identity" coordinate system.
Given this matrix (A) with a scale factors:
[ 2| 0 | 0 ]
[ 0 | 3| 0 ]
[ 0 | 0 | 1 ]
See what happens to the following points when transformed by A:
P (0, 0) --> P1 (0, 0) Zero times anything is zero. The origins
are coincident without translation.
P (1, 1) --> P1 (2, 3) This means that the point (1,1) in
coordinate system defined by matrix A is the same point as (2, 3) defined in
the identity coordinate system.
P (2, 100) --> P1 (4, 300)
This is the simplest transformation. Using the equasions, x' = ax + cy +
tX; y' = bx + dy + tY; it is easy to see that a scale matrix just multiplies
all x values by (a) (2 in this case) and all y values by (d) (3 in this
case) because the other terms evaluate to zero.
>
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
The center of rotation is VERY important. (more later)
The reason to use transformation matrices is that any 2D point in any
coordinate system can be converted to the same point in the "identity"
coordinate system at the maximum cost of 6 multiplication and 6 additions.
The matrix is so powerful because it can represent a coordinate system
consisting of any number of rotations about any number of different points;
It can include arbitrary scaling and translation. It can produced "skewed"
coordinate systems, etc. A single matrix can encapsulate all of that
complexity and the maximum cost to transform a point is still just 6
multiplies and 6 adds! You do not need to hand code trigonometry or use
computationally expensive functions like sin and cos. Matrices can be
easily combined to create yet more complex transformations.
Scaling and rotation always occur about the origin. If you want a
coordinate system that includes rotation about a point other than the
origin, you use the following pattern:
1) translate to center of rotation (redefine origin)
2) rotate
3) translate back (redefine origin)
example: // Rotate the coordinate system about the point 100, 30
translate 100, 30
rotate 60 deg.
translate -100, -30
Remember, points are not rotated. That makes no sense. The mapping from
one coordinate system to the "identity" coordinate system has been changed
to include rotation about a point.
>
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.