# Edit Create an Image Page: Silhouette Edges

To create an image page, simply complete the form below and then hit the 'Save Page' button at the bottom of the form. As you complete the form, remember that one of the main goals of the Math Images Project is to provide explanations of the images on our site at various levels, so that everyone can understand some of the math behind the images. Try to complete the form as fully as possible, but remember that other users will have the opportunity to add more information to your image pages in the future. Also, please note that by contributing to the Math Images Project, you agree to comply to the guidelines as stated in our general disclaimer.

As always, thank you for your contributions! --The Math Images Project

If you need help filling out this page, please consult our Help sections: Want to Contribute and Math Resources.

Note: * Indicates a required field.

Please note: When you are filling in the below explanations, you should feel free to use standard wikitext.

 Image Title*: Upload a Math Image This bunny is made up of a group a faces that are adjacent to one another. A program has been run on the object that has found the silhouette edges and they are highlighted in green. This is done by finding which faces have their [[Surface Normals|normals]] facing towards versus away from the viewer. If you have a 3D object, either surface or solid, a silhouette edge is the collection of points where the surface normal is orthogonal to the view vector.

If the object is composed of triangles, a silhouette edge is comprised of the common edges between a triangle whose surface normal points toward the viewer and a triangle whose surface normal points away from the viewer. The silhouette edge is a collection of these 'corner' edges, each between one triangle that faces toward and another that faces away from the viewer. This is then an algorithm for finding silhouette edges:
:For every triangle in the object ::Compute the surface normal of the triangle ::If the surface normal points toward the viewer :::For every edge of the triangle ::::Identify the triangle that shares this edge ::::Compute the surface normal for that triangle ::::If this surface normal points away from the viewer :::::Add the edge to the collection of silhouette edges ::::endif :::endfor ::endif :endfor

Implementing this algorithm requires some vector arithmetic, as described in the pages on [[Vector|vectors]] and [[Matrix|matrices]]. This includes computing and comparing the normal vectors for adjacent triangles, as described in the More Mathematical Explanation below.

==Computing the surface normal of a triangle== This is discussed in the page on [[Surface Normals]], but it involves the cross product of two vectors. These vectors may be
::(a) two adjacent edge vectors from a triangle, or
::(b) two tangent vectors at a point in the triangle computed by partial derivatives.
Cross products are order-sensitive, so you need to arrange these two vectors so that the angle between the first E1 and second E2 is positive in the usual sense, that is, that the second is counterclockwise from the first. Then the surface normal to the triangle is the cross product $N = E1 \times E2$. This is shown in the figure below:
[[Image:Computingsurfacenormal.jpg|400px|center]]
==Determining whether a surface triangle normal points toward the viewer== Once you have the triangle surface normal N, compute the view vector as the vector from the eyepoint to the point on the triangle you used in computing the normal; this is the view vector V. For this question we are more interested in the vector from the triangle to the eyepoint, but this is simply V’= –V. Then the surface normal points toward the eye if the angle between N and V’ is acute; this is true if the dot product N•V’ is positive, as shown in the figure below:
[[Image:Silhouettefacing.jpg|400px|center]]
The reason this is useful is to find the edges between triangles that are pointing toward the viewer and triangles that are pointing away from the viewer. This is where the silhouette edge is drawn. ==Example of a surface== Consider a surface such as this trig function surface shown in the figure below, given by the formula $f(x,y) = 0.3 \times \cos(x^2 +y^2 +t)$, with the parameter t intended to be varied continually giving an animation to the surface:
[[Image:Silhouettesurface.jpg|400px|center]]
If you use the technique of constructing a grid for the function domain (as described in the discussion of surfaces) you can identify the adjacent grid triangles for each triangle. Thus you can also get the adjacent triangles. Using these, you can compute the triangle surface normals with either approach described above.
==Example for an object== {{hide|1= Building an interesting graphical object is probably not an easy job, so you might look for other sources of examples. A good source might come from the might come from the publicly-available .obj files at sources named at ::[http://www.hongkiat.com/blog/60-excellent-free-3d-model-websites/ 3D Model Sites]
Below is an example: the Stanford bunny from ::[http://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj Stanford's Bunny Data]
The figure shows this with silhouette edges in green on top of a very restricted lighting, so you can tell what a silhouette edge might look like. Two other “canonical” .obj files for computer graphics, both having lots of interesting shapes, are the dragon and the happy Buddha you can find at ::[http://www.d.umn.edu/~ddunham/cs5721f07/schedule/resources/lab_opengl07.html University of Minnesota Duluth Computer Graphics]
[[Image:Silhouettebunny.png|200px|center]]
If you use a source such as the usual .obj files, you may have difficulty in figuring out which triangles are adjacent to one you are considering. However, some .obj files use triangles with adjacency rather than simple triangles. In this case, the primitives with adjacency we described in the section on [[Graphics Primitives|geometric primitives]] may help. As described there, a triangle with adjacency actually includes six points, as described by the figure below:
::[[Image:Silhouettetriangles.png|200px|center]]
So for any edge of the triangle with vertices 0, 2, and 4, you have the adjacent triangle, letting you compute all the triangle normals you need for the silhouette computation. The bunny figure above was computed from an .obj file that included this kind of adjacency. }} Algebra Analysis Calculus Dynamic Systems Fractals Geometry Graph Theory Number Theory Polyhedra Probability Topology Other None Algebra Analysis Calculus Dynamic Systems Fractals Geometry Graph Theory Number Theory Polyhedra Probability Topology Other None Algebra Analysis Calculus Dynamic Systems Fractals Geometry Graph Theory Number Theory Polyhedra Probability Topology Other Silhouette Edges are useful in graphics for more than just looking nice. They are sometimes an unseen step in a process to create something else. An example of this is line drawing. If you take a 3D model and find its silhouette edges, this can help create a 2D line drawing of the model. ==Shadow Volumes== Shadow volumes are used, not surprisingly, to create shadows. Instead of using the viewer (where the camera is) in this case we use the light source to find which triangles point toward and away. An example of a shadow volume can be seen below. Cutler, B. (2011). Advanced Computer Graphics. Note how the silhouette edges in red are the edges that would be silhouettes if you were viewing the scene from where the yellow dot (light source) is. The green volume is contained in the space bounded by rays coming from the light source, and passing through the silhouette edge.