i
i
i
i
i
i
i
i
48 2. Miscellaneous Math
where A is the area of the triangle. Note that A = A
a
+ A
b
+ A
c
, so it can be
computed with two additions rather than a full area formula. This rule still holds
for points outside the triangle if the areas are allowed to be signed. The reason
for this is shown in Figure 2.39. Note that these are signed areas and will be
computed correctly as long as the same signed area computation is used for both
A and the subtriangles A
a
, A
b
,andA
c
.
Figure 2.39. Theareaof
the two triangles shown is
base times height and are
thus the same, as is any tri-
angle with a vertex on the
β = 0.5 line. The height
and thus the area is propor-
tional to β.
2.7.2 3D Triangles
One wonderful thing about barycentric coordinates is that they extend almost
transparently to 3D. If we assume the points a, b,andc are 3D, then we can
still use the representation
p =(1−β − γ)a + βb + γc.
Now, as we vary β and γ, we sweep out a plane.
The normal vector to a triangle can be found by taking the cross product of
any two vectors in the plane of the triangle (Figure 2.40). It is easiest to use two
of the three edges as these vectors, for example,
n =(b − a) × (c − a). (2.35)
Note that this normal vector is not necessarily of unit length, and it obeys the
right-hand rule of cross products.
Figure 2.40. The nor-
mal vector of the triangle is
perpendicular to all vectors
in the plane of the triangle,
and thus perpendicular to
the edges of the triangle.
The area of the triangle can be found by taking the length of the cross product:
area =
1
2
(b − a) ×(c − a). (2.36)
Note that this is not a signed area, so it cannot be used directly to evaluate barycen-
tric coordinates. However, we can observe that a triangle with a “clockwise” ver-
tex order will have a normal vector that points in the opposite direction to the
normal of a triangle in the same plane with a “counterclockwise” vertex order.
Recall that
a · b = ab cos φ,
where φ is the angle between the vectors. If a and b are parallel, then cos φ = ±1,
and this gives a test of whether the vectors point in the same or opposite directions.