Graphics Reference
In-Depth Information
In that any line L parallel to n serves as a separating axis, a good choice is to have
L go through the box center, giving L as L ( t )
=
C
+
t n . The box center C projects
onto L at t
0. Because the OBB is symmetrical about its center, the projection onto
L results in a symmetric interval of projection
=
, centered at C , with
a halfwidth (or radius) of r . Testing if B intersects P now amounts to computing the
radius r of the projection interval and checking if the distance of the center point of
B to P is less than r .
Because points of the OBB farthest away from its center are the vertices of the OBB,
the overall maximum projection radius onto any vector n will be realized by one of
the vertices. Thus, it is sufficient to consider only these when computing the radius
r . The projection radii r i of the eight vertices are given by
[
C
r n , C
+
r n
]
r i
=
( V i
C )
·
n
=
( C
±
e 0 u 0
±
e 1 u 1
±
e 2 u 2
C )
·
n
=
(
±
e 0 u 0
±
e 1 u 1
±
e 2 u 2 )
·
n .
Due to the distributive properties of the dot product, this expression can be
written as
r i
( e 0 u 0
·
n )
±
( e 1 u 1
·
n )
±
( e 2 u 2
·
n ).
The maximum positive radius r is obtained when all involved terms are positive,
corresponding to only positive steps along n , which is achieved by taking the absolute
value of the terms before adding them up:
r
= |
e 0 u 0 ·
n
| + |
e 1 u 1 ·
n
| + |
e 2 u 2 ·
n
|
.
Because the extents are assumed positive, r can be written as
r
=
e 0 |
u 0 ·
n
| +
e 1 |
u 1 ·
n
| +
e 2 |
u 2 ·
n
|
.
When the separating-axis vector n is not a unit vector, r instead becomes
)
r
=
( e 0
|
u 0
·
n
| +
e 1
|
u 1
·
n
| +
e 2
|
u 2
·
n
|
n
.
The signed distance s of C from P is obtained by evaluating the plane equation
for C , giving s
=
n
·
C
d . Another way of obtaining s is to compute the distance
u of P from C , s
n for some point
Q on the plane. As all points on P project to a single point on L , it is sufficient to
work with the projection of Q onto L . The distance u can therefore be computed as
u
=−
u . Recall that P is n
·
X
=
d , where d
=
Q
·
=
·
=
·
·
=
·
( Q
C )
n
Q
n
C
n
d
C
n , which up to a sign change is equivalent
Search WWH ::




Custom Search