Graphics Reference
In-Depth Information
W
P 2
V
P 1
A
B
P 1
sV
P 2 B tW
A
FIGURE B.13
Two lines are closest to each other at points
P 1 and
P 2 .
B.2.7 Area calculations
Area of a triangle
The area of a triangle consisting of vertices V 1 , V 2 , V 3 is one-half times the length of one edge times the
perpendicular distance from that edge to the other vertex. The perpendicular distance from the edge to a
vertex can be computed using the cross-product (see Figure B.14 ). For triangles in two dimensions, the
z -coordinates are essentially considered zero and the cross-product computation is simplified accord-
ingly (only the z -coordinate of the cross-product is non-zero).
The signed area of the triangle is required for computing the area of a polygon. In the two-
dimensional case, this is done simply by not taking the absolute value of the z -coordinate of
the cross-product. In the three-dimensional case, a vector normal to the polygon can be used to indi-
cate the positive direction. The direction of the vector produced by the cross-product can be com-
pared to the normal (using the dot product) to determine whether it is in the positive or negative
direction. The length of the cross-product vector can then be computed and the appropriate sign
applied to it.
1
2
1
2
1
2
V 1
Area( V 1 , V 2 , V 3 ) V 2 V 3 V 1 V 3 sin
V 2 V 3 ( V 1 V 3 ) ( V 2 V 3 )
V 2 V 3
( V 1
V 3 )
( V 2
V 3 )
V 2
V 3
V 1
V 2
V 3
 
Search WWH ::




Custom Search