Graphics Reference
In-Depth Information
with a mouse-click position pt dc :
pt dc =(
x dc ,
y dc ) ,
or expressed as a vector:
V dc = x dc y dc .
DC-to-NDC transform. Recall that in 2D, the NDC space is
NDC space:
1
x ndc
1
,
1
y ndc
1
.
×
To transform from DC to NDC space, we scale the DC space down to 2
2and
then translate the center of the region to the origin, or:
2
W dc ,
2
H dc )
V ndc =
V dc S
(
T
(
1
,−
1
) .
Expanding the scale and translation operators, we get
= x ndc y ndc
V ndc
= x dc y dc S
2
2
(
W dc ,
H dc )
T
(
1
,−
1
)
2 x dc
W dc
H dc T
2 y dc
=
(
1
,−
1
)
2 x dc
1
2 y dc
W dc
H dc
=
1
,
or
2
×
x dc
x ndc =
W dc
1
,
(15.6)
2 × y dc
y ndc =
H dc
1
.
Because the mouse-click position is in 2D, we cannot compute the z -component
for the transformed NDC result. In other words, any z value is valid, or
x ndc y ndc z ndc
V ndc =
,
where (from Equation (15.6)):
2 × x dc
x ndc =
W dc
1
,
2
×
y dc
y ndc =
H dc
1
,
1
z ndc
0
.
As illustrated in Figure 15.12, V ndc actually defines a line in the NDC space.
The mouse-click position can be considered to be located on the near plane with
(
x ndc ,
y ndc ,
0
)
, which defines a line that is parallel to the z -axis and exists from the
far plane at
(
x ndc ,
y ndc ,−
1
)
.
Search WWH ::




Custom Search