Graphics Reference
In-Depth Information
The scaling action is relative to the origin, i.e. the point (0,0) remains (0,0)
All other points move away from the origin. To scale relative to another point
( p x ,p y ) we first subtract ( p x ,p y )from( x , y ) respectively. This effectively trans-
lates the reference point ( p x ,p y ) back to the origin. Second, we perform the
scaling operation, and third, add ( p x ,p y )backto( x , y ) respectively, to com-
pensate for the original subtraction. Algebraically this is
x = s x ( x
p x )+ p x
y = s y ( y − p y )+ p y
(7.25)
which simplifies to
x = s x x + p x (1
s x )
y = s y y + p y (1
s y )
(7.26)
or in a homogeneous matrix form
x
y
1
s x
0
p x (1
s x )
x
y
1
=
.
0
s y
p y (1
s y )
(7.27)
00
1
For example, to scale a shape by 2 relative to the point (1, 1) the
matrix is
x
y
1
20
1
x
y
1
=
·
02
1
00 1
7.3.3 2D Reflections
The matrix notation for reflecting about the y -axis is:
x
y
1
100
010
001
x
y
1
=
·
(7.28)
or about the x -axis
x
y
1
100
0
x
y
1
=
.
10
001
(7.29)
However, to make a reflection about an arbitrary vertical or horizontal
axis we need to introduce some more algebraic deception. For example, to
make a reflection about the vertical axis x = 1, we first subtract 1 from the
x -coordinate. This effectively makes the x = 1 axis coincident with the major
y -axis. Next we perform the reflection by reversing the sign of the modified
Search WWH ::




Custom Search