Graphics Reference
In-Depth Information
that is, it's the distance to the closest point in
S
.If
S
divides space into a
well-defined inside and outside, then the
signed distance function
is
distance
S
(
x
):
x
is outside
,
−
φ
S
(
x
)=
distance
S
(
x
):
x
is inside
.
From now on we'll drop the subscript
S
and just call it
φ
(
x
). Points exactly
on the surface
S
have distance and signed distance equal to zero, regardless
of whether they are included in the inside or outside. (By convention in this
topic we'll include
S
with the inside region.) Therefore, both the distance
function and the signed distance function can be used to implicitly describe
the underling surface:
S
is the set of points where distance
S
(
x
)or
φ
(
x
)are
zero, the zero level set or isocontour.
Signed distance has many useful properties. For example, at some point
x
inside the surface, let
n
be the unit-length direction toward the closest
point on the surface. Notice that for positive
small enough, the signed
distance
φ
(
x
+
n
)mustbe
φ
(
x
)+
: if I move along this direction
n
,my
closest point on the surface doesn't change, and my distance to it changes
by exactly how much I move. Therefore the directional derivative of
φ
in
this direction is 1:
∇
φ
·
n
=1
.
Also notice that if I move in any other direction,
φ
cannot change any
faster—the fastest way to increase or decrease my distance to the surface
is obviously to move along the direction to the closest point. Thus, the
gradient of
φ
, which is the direction of steepest ascent, must in fact be the
direction
n
to the closest point on the surface:
φ.
Exactly the same result holds outside the surface. Putting the two previous
equations together, we see
n
=
∇
= 1 wherever it exists.
It can be shown that in fact signed distance is smooth (i.e.,
∇φ
and
higher derivatives exist) everywhere except on the
medial axis
, consisting
of points that are equidistant to different parts of the surface, and for
reasonable surfaces this is a small, lower-dimensional set indeed—and even
on the medial axis, it's still continuous, just with a kink. In particular,
if the surface itself is smooth, signed distance is smooth on and near the
surface. (In contrast, regular distance has a non-differentiable kink right
along
S
, making it decidedly less attractive numerically.) Another nice
feature that falls out of this is that for any point
x
, the closest point on
the surface is located at
x
∇
φ
−
φ
(
x
)
∇
φ
(
x
).