Java Reference
In-Depth Information
A translation is one kind of affine transformation . Affine is a funny word. Some say it goes back to Laurel
and Hardy where Ollie says, "This is affine mess you've got us into", but I don't subscribe to that. An affine
transformation is actually a linear transformation that leaves straight lines still straight and parallel lines still
parallel. As well as translations, there are other kinds of affine transformation that you can define:
Rotation - the user coordinates system is rotated through a given angle about its origin.
Scale - the x and y coordinates are each multiplied by a scaling factor, and the multipliers for
x and y can be different. This enables you to enlarge or reduce something in size. If the scale
factor for one coordinate axis is negative, then objects will be reflected in the other axis.
Setting the scale factor for x coordinates to -1, for example, will make all positive coordinates
negative and vice versa so everything is reflected in the y axis.
Shear - this is perhaps a less familiar operation. It adds a value to each x coordinate that
depends on the y coordinate, and adds a value to each y coordinate that depends on the x
coordinate. You supply two values to specify a shear, sX and sY say, and they change the
coordinates in the following way:
Each x coordinate becomes ( x + sX * y)
Each y coordinate becomes ( y + sY * x )
The effect of this can be visualized most easily if you first imagine a rectangle that is drawn
normally. A shearing transform can squash it by tilting the sides - rather like when you flatten
a carton - but keep opposite sides straight and parallel.
Device Coordinates
x
Device Coordinates
x
Device Coordinates
x
User Coordinates
x
User Coordinates
x
y
y
y
y
y
What was here
now appears here
What was like this
could appear like
this
What was like this
could appear like
this
Rotation
Scaling
Shearing
The illustration shows:
A rotation of -
/4 radians, which is -45 degrees. Rotation angles are expressed in radians and
a positive angle rotates everything from the positive x-axis towards the positive y-axis -
therefore clockwise. The rotation in the illustration is negative and therefore counterclockwise.
π
A scaling transformation corresponding to an x scale of 2.5 and a y scale of 1.5.
A shearing operation where only the x coordinates have a shear factor. The factor for the y
coordinates is 0 so they are unaffected and the transformed shape is the same height as the original.
Search WWH ::




Custom Search