Graphics Reference
In-Depth Information
the OBB space, after which both can be translated to the origin in the same way as
for the AABB. Assuming the OBB is given by a center point
C
; a halfwidth extent
vector
e
(
e
0
,
e
1
,
e
2
); and local coordinate axes
u
0
,
u
1
, and
u
2
; then a point
P
in world
space can be expressed in the OBB coordinate system as the point (
x
,
y
,
z
), where
x
=
=
(
P
−
C
)
·
u
0
,
y
=
(
P
−
C
)
·
u
1
, and
z
=
(
P
−
C
)
·
u
2
.
Let the segment be described by a midpoint
M
=
(
m
x
,
m
y
,
m
z
) and endpoints
M
−
d
and
M
+
d
, where
d
=
(
d
x
,
d
y
,
d
z
) is a direction vector for the segment. The
halflength of the segment is
d
. Projecting the segment onto some separating axis
v
(
v
x
,
v
y
,
v
z
) through the origin results in a projection interval centered at a signed
distance
d
s
=
=
v
)
(
M
·
v
away from the origin (along
v
), with a radius (or halflength)
of
r
s
=
d
v
·
v
. Letting
r
b
denote the projection interval radius of the box onto
the vector
v
,
v
acts as a separating axis if and only if
d
s
>
r
s
(Figure 5.23).
For an OBB specified by three orthogonal unit vectors
u
0
,
u
1
, and
u
2
and three
halflength extents
e
0
,
e
1
, and
e
2
, the projection interval radius
r
b
is given by
r
b
+
)
=
(
e
0
|
·
| +
e
1
|
·
| +
e
2
|
·
|
r
b
u
0
v
u
1
v
u
2
v
v
.
By substituting
u
0
=
(1,0,0),
u
1
=
(0, 1, 0), and
u
2
=
(0, 0, 1), the corresponding
expression for an AABB is given by
e
1
v
y
+
)
r
b
=
(
e
0
|
v
x
| +
e
2
|
v
z
|
v
.
M
+
v
M
M
-
v
V
k
r
s
C
r
b
d
s
Figure 5.23
Testing intersection between a segment and an AABB using a separating-
axis test.