Graphics Reference
In-Depth Information
7.10.7 Analogs of Barycentric Coordinates
Barycentric coordinates provide a very useful way to discuss point locations
within a triangle, because they are invariant under affine transformations. That
is, if the point Q has barycentric coordinates ( s 0 , s 1 , s 2 ) in the triangle P 0 P 1 P 2 ,
and we transform the triangle by applying the same transformation T to each P i
and to Q , and if T is an affine transformation —that is, a rotation, a translation,
a dilation, or a combination of these—then the barycentric coordinates of T ( Q )
in the triangle T ( P 0 ) T ( P 1 ) T ( P 2 ) will still be ( s 0 , s 1 , s 2 ) . Furthermore, on the edge
between P 0 and P 1 ,wehave s 2 = 0, and similarly for the other two edges. The
barycentric coordinates are all positive for points inside the triangle, but for any
point outside the triangle, at least one barycentric coordinate is negative. Is there
an analogous set of “coordinates” for a point in a polygon? Warren and others have
studied this question extensively, developing generalized barycentric coordinates
for points in a convex polygon or set [War96] [WSHD04] and a generalization to
coordinates that use all points of a mesh to define coordinates on points in and
around that mesh [JSW05].
7.11 Discussion
The lessons to take away from this chapter are as follows.
• Be careful to say what you mean precisely when you use mathematics. Give
your functions both domains and codomains; examine what happens when
a formula could lead to a division by zero; and generalize to n dimensions
whenever possible to better understand the intrinsic nature of the problem
you're solving.
• Whenever possible, express computations that need to be done in R 2 or
R 3 as vector computations, involving vector operations, point-vector com-
binations, point-point differences, and inner products, and thereby avoid
per-coordinate expressions.
• Try to understand geometric problems geometrically rather than in terms
of coordinates; use coordinates for computations only.
These approaches lead to clearer understanding and more easily maintainable
programs, and can often lead to insights about algorithms because the compact-
ness of well-expressed mathematics allows us to see patterns that might otherwise
be obscure.
7.12 Exercises
Exercise 7.1: (a) Show that if s is a number and v is a vector, then
s v
=
|
s
|
v
.
(b) Give an example of a number s and vector v for which
.
Exercise 7.2: We showed how to get from a point P on a line and a vector n
normal to the line to the more familiar Ax + By + C = 0 form. Figure out how to
go the other way: Given a line defined by Ax + By + C = 0, with at least one of A
and B nonzero, find a point on the line. Hint: A normal vector to the line is given
s v
= s
v
by n = A
B
. Use this to determine a point of the form O +
α
n (where O is the
origin) that lies on the line, by solving for
α
.
 
 
 
 
Search WWH ::




Custom Search