summaryrefslogtreecommitdiffstats
path: root/debian/fireflies/fireflies-2.08/libgfx/doc/geom3d.html
blob: 549aa7a7df8362b5e3bfe71349afc88e2083a3ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
		      "http://www.w3.org/TR/REC-html40/loose.dtd">
<!-- $Id: geom3d.html 160 2000-09-05 19:44:15Z garland $ -->

<html>

<head>
<title>libgfx: 3-D Geometric Procedures</title>
<link rel=stylesheet href="cdoc.css" type="text/css">
<meta name="Author" content="Michael Garland">
</head>

<body>

<h2>3-D Geometric Procedures</h2>

<p>Triangles are a very common modeling primitive in many graphics
applications.  The <tt>libgfx</tt> library provides a package of routines for
computing various geometric properties of triangles.
To use this package you must include the standard header file
<pre>
    #include &lt;gfx/geom3d.h&gt;
</pre>
Note that all of these functions assume that the corners of the triangle are
listed in <em>counter-clockwise order</em> around the outward pointing normal.

<p>You can compute the (signed) area of a triangle using the following
function.  Note that the area will be negative if the vertices are listed in
clockwise order.
<pre>
    double triangle_area(const Vec3&amp;, const Vec3&amp;, const Vec3&amp;);
</pre>

<p>The following functions compute the plane defined by a triangle, and the
corresponding normal vector.  The standard versions always use unit normal
vectors while the "raw" versions will use unscaled normals.
<pre>
    Vec3 triangle_normal(const Vec3&amp;, const Vec3&amp;, const Vec3&amp;);
    Vec4 triangle_plane(const Vec3&amp;, const Vec3&amp;, const Vec3&amp;);

    Vec3 triangle_raw_normal(const Vec3&amp;, const Vec3&amp;, const Vec3&amp;);
    Vec4 triangle_raw_plane(const Vec3&amp;, const Vec3&amp;, const Vec3&amp;);
</pre>


<p>For some meshing applications, it may on occasion be necessary to assess
the aspect ratio of a triangle.
<pre>
    double triangle_compactness(const Vec3&amp;, const Vec3&amp;, const Vec3&amp;);
</pre>
This function computes the "compactness" of a triangle.  The returned value
will be between 0 and 1, with 0 meaning a degenerate (area=0) triangle and 1
meaning an equilateral triangle.  The formula used, originally suggested by
Andre Gueziec, is 4*sqrt(3) * Area / (L1 + L2 + L3) where Li is the squared
length of side <i>i</i> of the triangle.

</body>

</html>