Graphics Primitives

From Math Images

Revision as of 15:02, 7 July 2011 by Nordhr (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search
Image:inprogress.png

Graphics Primitives

placeholder


Contents

Basic Description

The basic idea of computer graphics is for the computer to draw the geometry you want to see. But “drawing geometry” is a pretty abstract idea; to make it concrete you need to describe the geometry in a way the computer can use it.

There are different kinds of computer graphics, and they sometimes have different kinds of primitives. These might include explicit objects, like geometric solids, geometric surfaces, or implicit objects – objects defined by mathematical expressions. For now, we will consider graphics primitives defined by points, line segments, and polygons, or polygon-based computer graphics.

A More Mathematical Explanation

Basic Primitives

Examples of these primitives are shown in the figure below; these include points [...]

Basic Primitives

Examples of these primitives are shown in the figure below; these include points, line segments, triangles, quads, and polygons.


Points and line segments are, of course, irreducible, but quads and polygons are not; in this example it’s easy to see how we can re-define the quad or polygon as sets of triangles.


Sometimes we may want to go beyond a single primitive to a structured collection of simple primitives that can be used efficiently in defining more complex objects. There are three of these: triangle strips, triangle fans, and, quad strips, as shown in the figure below.


In the previous figure, we see that the quad was replaced by a triangle strip and the polygon by a triangle fan.

As an example of how these primitives can be used in an actual object, let’s look at a way to draw a sphere. We can first define a set of vertices on the sphere that define a mesh for the object, and then can use quad strips and triangle fans to fill in the surface of the sphere, as shown in the figure below.


Now quad strips themselves aren’t irreducible. They can be written as triangle strips, as below, leading us to understand that triangles are fundamentally more basic than quads.


There are many ways to simplify this definition. For example, it’s enough to have every line segment between vertices of the polygon lie within the polygon. This, in turn, leads to an operational definition that is very useful for graphics: a polygon is convex precisely if it can be created as a triangle fan from every vertex. As we said above, convex polygons are really just made up of triangles.

There’s one more observation about convex polygons that we’ll make here, but we’ll come back to it again when we talk about interpolations, where it really belongs. We’ll define a convex sum of a collection {Ai} of objects as a sum where each is non-negative and . It’s fairly straightforward, and a pretty good exercise, to show that a polygon is convex precisely if each interior and boundary point can be written as a convex sum of the polygon’s vertices.


Convex polygons

A very critical point for graphics is that most (if not all) graphics systems can only reliably draw convex primitives. There are many ways to define what it means for a polygon to be convex; probably the simplest is the property that for any two points in (or on the boundary of) the primitive, the line segment between them lies within (or on the boundary of) the primitive. In the figure below, the left-hand polygon is convex, while neither of the others are.


There are many ways to simplify this definition. For example, it’s enough to have every line segment between vertices of the polygon lie within the polygon. This, in turn, leads to an operational definition that is very useful for graphics: a polygon is convex precisely if it can be created as a triangle fan from every vertex. As we said above, convex polygons are really just made up of triangles.

There’s one more observation about convex polygons that we’ll make here, but we’ll come back to it again when we talk about interpolations, where it really belongs. We’ll define a convex sum of a collection {Ai} of objects as a sum where each is non-negative and . It’s fairly straightforward, and a pretty good exercise, to show that a polygon is convex precisely if each interior and boundary point can be written as a convex sum of the polygon’s vertices.

This leads us to a very important observation about computer graphics primitives:

It's all about the triangles.



That is, in order to do polygon-based graphics, it’s enough to be able to define all your graphical objects by triangles and then to be able to display any triangles.

Making 3D objects from primitives

To move from 2D objects to 3D objects, we start by observing that any 2D object can be considered as a 3D object by simply adding an additional dimension that has a constant value. A simple triangle in the XY-plane can be embedded in 3D space by converting each vertex (x, y) to the point (x, y, 0). So in some sense, 2D graphics is simply a special case of 3D graphics.

A common use of graphics is to display surfaces. A surface is a two-dimensional manifold, which basically means that at each point on the surface, there is a local two-dimensional coordinate system. A simple example of a surface is shown in the figure below.


Since a surface is fundamentally a 2D object, even in 3D space, it can be treated similarly to a 2D space by creating a 2D array of 2D points. You can then draw the surface by taking 3D triangles from the 2D array and drawing them. You can see the details in the pages on surfaces.

For solid figures we introduce the notion of a polytope, a solid whose faces are polygons. While we have a single name for them, they aren’t themselves simple; the figure below shows three polytopes that are the three states of the character bit from the original movie Tron. The central solid is the ‘yes’ state, a simple octagon, while the solid on the left is the ‘neutral’ state and the rather jagged object on the right is the ‘no’ state.


You can create all sorts of 3D objects like this by simply creating any set of 2D faces that bound a closed space without self-intersections.

Storing 3D objects for computation

There are many ways you can store the data for a polytope, but the figure below shows a fairly common approach. This example shows how this can be done for a cube. First you store an array of the eight vertices of the cube in an order that makes it straightforward to keep track of them. Then you store an array that contains six faces of the cube as vectors of indices into the vertex array. The order of the vertices for each face is important; the standard approach is to store the vertex indices in counterclockwise order around the face as viewed from outside the object. [This orientation has the surface normal for each face pointing outward from the object, as we will see in the page on Surface Normals.]




Teaching Materials

There are currently no teaching materials for this page. Add teaching materials.




References

references





If you are able, please consider adding to or editing this page!

Have questions about the image or the explanations on this page?
Leave a message on the discussion page by clicking the 'discussion' tab at the top of this image page.






Personal tools