Triangle

From DmWiki

A triangle is the basic unit of 3D graphics. Thousands or millions of triangles are combined in a mesh to form more complex shapes or models. Triangles are used in 3D graphics because they are very simple to work with. They are made up of three vertices, making them planar. One of the triangle's basic properties is that it's three enclosed angles always sum up to 180°. Furthermore, they are guaranteed to be convex in shape.

Points on triangles can be identified using barycentric coordinates.

Table of contents

Math & Triangles

Trigonometry is the mathematical study of triangles, or using the Greek word, the measurement of triangles. Using trigonometry, you can find unknown angles between sides and the lengths of a side for a triangle.

The right triangle

Enlarge

A right triangle is defined as a triangle with one angle being 90 degrees. Right triangles are interesting because they have certain properties that make them useful in many situations in computer graphics computations.

Pythagorean Theorem

The Pythagorean Theorem is probably the most well-known property of the right triangle. It states that the squared length of the hypotenuse (marked as side c here) is equal to the sum of the squared length of the remaining sides.

c2 = a2 + b2

The reasoning behind this is that the sum of the areas, of two squares with the side lengths of a and b, equals the area of the square with the side length c.

By rearranging the equation, each side can be computed from the other two sides.

Relations between triangle side lengths

These are the standard ratios between sides for a triangle:

\sin = \frac{opposite}{hypotenuse}
\cos = \frac{adjacent}{hypotenuse}
\tan = \frac{opposite}{adjacent}

These are the inverses of the standard ratios:

\sec = \frac{1}{\sin} = \frac{hypotenuse}{opposite}
\csc = \frac{1}{\cos} = \frac{hypotenuse}{adjacent}
\cot = \frac{1}{\tan} = \frac{adjacent}{opposite}

Pythagorean Identities

The Pythagorean Identities can be derived from the Pythagorean Theorem, which gives the following:

sin2 + cos2 = 1
tan2 + 1 = sec2
cot2 + 1 = csc2

The General Triangle

General triangles are triangles which do not have a 90 degree angle, including isosceles triangles, equilateral triangles, obtuse triangles, and acute triangles. Unfortunately, the Pythagorean Theorem cannot be used to solve for general triangles.

Law of Sines

The Law of Sines states:

\frac{\sin A}{a} = \frac{\sin B}{b} = \frac{sin C}{c}

where A, B, C are angles and a, b, c are side lengths. The side a is opposite the angle A, and so forth.

Using the Law of Sines, if you know the sine of an angle and the length of the side, you can solve for the rest of the unknown sides.

Law of Cosines

The Law of Cosines is used to find the lengths of a side for a general triangle.

a^{2} + c^{2} - 2ac\, \cos B = b^{2}
a^{2} + b^{2} - 2ab\, \cos C = c^{2}
b^{2} + c^{2} - 2bc\, \cos A = a^{2}

Heron's Formula

Finding the area for a right triangle is easy (Base * Height / 2). Unfortunately, general triangles are a bit more complicated. Thanks to Heron, a long dead Greek architect, we have a formula which can find the area of any triangle.

Area = \sqrt{S(S-a)(S-b)(S-c)} where
S = \begin{matrix}\frac{1}{2}\end{matrix}(a+b+c)

Degenerate Triangle

A degenerate triangle is a polygon with three vertices that don't form a triangle. This happens when the three vertices are all on the same line (assuming euclidean geometry). In the extreme case all vertices share the same location and the triangle degenerates to a singular point.

Triangles & Game Development

Todo

See Also

This article is a stub. You can help improve the article by expanding it.


DevMaster navigation