Graphics Reference
In-Depth Information
7.3.7 2D Reflections
A reflection about the
y
-axis is given by
⎡
⎤
⎡
⎤
⎡
⎤
x
y
1
−
100
010
001
x
y
1
⎣
⎦
=
⎣
⎦
·
⎣
⎦
(7.45)
Therefore, using matrices, we can reason that a reflection transform about an
arbitrary axis
x
=
a
x
, parallel with the
y
-axis, is given by
⎡
⎤
⎡
⎤
x
y
1
x
y
1
⎣
⎦
= [translate(
a
x
,
0)]
⎣
⎦
·
[reflection]
·
[translate(
−
a
x
,
0)]
·
which expands to
⎡
⎤
⎡
⎤
⎡
⎤
⎡
⎤
⎡
⎤
x
y
1
10
a
x
01 0
00 1
−
100
010
001
10
a
x
01 0
00 1
−
x
y
1
⎣
⎦
=
⎣
⎦
·
⎣
⎦
·
⎣
⎦
·
⎣
⎦
We can now concatenate these matrices into a single matrix by multiplying
them together. Let's begin by multiplying the reflection and the translate
(
−
a
x
,
0) matrices together. This produces
⎡
⎤
⎡
⎤
⎡
⎤
⎡
⎤
x
y
1
10
a
x
01 0
00 1
−
10
a
x
01 0
00 1
x
y
1
⎣
⎦
=
⎣
⎦
·
⎣
⎦
·
⎣
⎦
and finally
⎡
⎤
⎡
⎤
⎡
⎤
x
y
1
−
10
a
x
01 0
00 1
x
y
1
⎣
⎦
=
⎣
⎦
·
⎣
⎦
(7.46)
which is the same as the previous transform (7.33).
7.3.8 2D Rotation about an Arbitrary Point
A rotation about the origin is given by
⎡
⎤
⎡
⎤
⎡
⎤
x
y
1
cos(
β
)
−
sin(
β
)0
x
y
1
⎣
⎦
=
⎣
⎦
·
⎣
⎦
sin(
β
)
cos(
β
)0
(7.47)
0
0
1
Therefore, using matrices, we can develop a rotation about an arbitrary point
(
p
x
,p
y
) as follows:
⎡
⎤
⎡
⎤
x
y
1
x
y
1
⎣
⎦
= [translate(
p
x
,p
y
)]
⎣
⎦
·
[rotate
β
]
·
[translate(
−
p
x
,
−
p
y
)]
·