Docsity

Computer Graphics Project Report: Intersection and Difference of Triangles - Prof. Jarosla, Study Guides, Projects, Research of Computer Graphics

Toggle sidebar
bg1
CS6491 Computer Graphics
Project 2 Report
Prof. Jarek Rossignac
Student: Yong-Dian Jian
1) Problem definition: Given two triangles (polygons), find out and give different colors to the boundaries
and interior regions of the intersection/difference/union of these two triangles (polygons).
2) Idea of my solution: (a) Find out the intersection points between two triangles. (b) Decompose the
edges into segments according to the intersection points. (c) Maintain the connectivity relationship
between the vertices and segments. (d) Give every vertex or segment two labels: The first label
indicates whether this vertex/segment lies on the interior/boundary/exterior of the first triangle. The
second label indicates the same thing for the second triangle. (e) According to the definition of the
logical operations, intersection, difference and union, we can define criteria to classify whether the
vertices and segments belong to the boundaries of these regions. (f) According to the classification
criteria, we can trace the vertices and segments and then complete the desired polygons. Figure 1
shows the snapshots of my program. Notice that my solution can handle polygons.
(a) (b) (c)
(d) (e) (f)
Fig. 1: Snapshots of my program. (a)(d) Triangle, (b)(e) Quadrangle and (c)(f) Pentagon.
3) Detection of near singularities: I did several things for near singularity. (a) I examine whether
a triangle contains another triangle. This case generates no intersections between two triangles. I
implement this test by checking six times whether a point lies inside a triangle. (b) I also examine
whether a vertex lies on the boundary of another triangle. I implement this test by checking six times
whether a point lies on the triangle edge.
4) How do I divide the edges into segments? For each triangle edge, I find the intersection points
between this edge and the edges of the other triangle. It is done by performing three times of
intersection tests between every two edges. If there are multiple intersections, I will sort their orders
along the edge and then split the edge into disjoint segments. In this process, I will maintain the
connectivity relationship between vertices (intersection points) and segments. This information will
September 10, 2008
pf2

Partial preview of the text

Download Computer Graphics Project Report: Intersection and Difference of Triangles - Prof. Jarosla and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

CS6491 Computer Graphics Project 2 Report

Prof. Jarek Rossignac Student: Yong-Dian Jian

  1. Problem definition: Given two triangles (polygons), find out and give different colors to the boundaries and interior regions of the intersection/difference/union of these two triangles (polygons).

  2. Idea of my solution: (a) Find out the intersection points between two triangles. (b) Decompose the edges into segments according to the intersection points. (c) Maintain the connectivity relationship between the vertices and segments. (d) Give every vertex or segment two labels: The first label indicates whether this vertex/segment lies on the interior/boundary/exterior of the first triangle. The second label indicates the same thing for the second triangle. (e) According to the definition of the logical operations, intersection, difference and union, we can define criteria to classify whether the vertices and segments belong to the boundaries of these regions. (f) According to the classification criteria, we can trace the vertices and segments and then complete the desired polygons. Figure 1 shows the snapshots of my program. Notice that my solution can handle polygons.

(a) (b) (c)

(d) (e) (f) Fig. 1: Snapshots of my program. (a)(d) Triangle, (b)(e) Quadrangle and (c)(f) Pentagon.

  1. Detection of near singularities: I did several things for near singularity. (a) I examine whether a triangle contains another triangle. This case generates no intersections between two triangles. I implement this test by checking six times whether a point lies inside a triangle. (b) I also examine whether a vertex lies on the boundary of another triangle. I implement this test by checking six times whether a point lies on the triangle edge.

  2. How do I divide the edges into segments? For each triangle edge, I find the intersection points between this edge and the edges of the other triangle. It is done by performing three times of intersection tests between every two edges. If there are multiple intersections, I will sort their orders along the edge and then split the edge into disjoint segments. In this process, I will maintain the connectivity relationship between vertices (intersection points) and segments. This information will

September 10, 2008

CS6491 Computer Graphics Project 2 Report

Prof. Jarek Rossignac Student: Yong-Dian Jian

be used to trace the boundary of the desired polygons. In addition, I will give labels to vertices and segments to identify whether they are inside, outside or on the boundary of the two triangles. The labels of vertices can be calculated by performing some Point-in-Triangle tests. To get the labels of the segments along an edge, a bit variable is maintained to indicate the property (interior/exterior) of the following segment. This technique is similar to that used in the Point-in-Polygon test. We start from a vertex of the triangle. Each time a intersection point is met, the bit is reversed. In this way, we can give labels to all the vertices, intersection points and segments.

  1. How do I classify the segments for each logical operation? It should be discussed in three separate cases. Let S 1 , S 2 are the two triangles. Below we adopt some topology notations introduced in the class to make our explanation precise. Intersection The segments on the boundary of the intersection of S 1 and S 2 (i.e. (S 1

S2).b) should belong to (S 1 .b

S 2 .i) or (S 1 .i

S 2 .b). Likewise, the vertices of this class should belong to (S 1 .b

S 2 .b), (S 1 .b

S 2 .i) or (S 1 .i

S 2 .b). Difference The segments on the boundary of the difference between S 1 and S 2 (i.e. (S 1 − S2).b) should belong to (S 1 .b

S 2 .e) or (S 1 .i

S 2 .b). The vertices of this class should belong to (S 1 .b

S 2 .b) or (S 1 .b

S 2 .e). Union The segments on the boundary of the union of S 1 and S 2 (i.e. (S 1

S2).b) should belong to (S 1 .b

S 2 .e) or (S 1 .e

S 2 .b). The vertices of this class should belong to (S 1 .b

S 2 .b), (S 1 .b

S 2 .e) or (S 1 .e

S 2 .b).

  1. How do I link the segments into loops and fill the regions? With the connectivity relationship built in the previous stage, and the classification criteria for vertices and segments, we can find an initial valid vertex or segment and then trace the boundary of the desired polygon. Notice that a set of binary variables is used to track whether a vertex is already visited before. Filling the interior region of a convex polygon is easy, but it is uneasy to fill a concave polygon. I did some research on this topic and found that a known technique, polygon triangulation [1], might be useful to decompose concave polygons into triangles. I also found a polygon triangulation library [2] online. Although it really works, its speed is unacceptable for live demo, so I didn’t put it in my program. Currently, I didn’t handle the filling of concave polygons very well.

  2. Extension to simple polygonal regions: As shown in Figure 1, my solution can be generalized to handle simple polygons without modifying the core algorithm.

REFERENCES

[1] http://en.wikipedia.org/wiki/Polygon triangulation [2] http://www.codeproject.com/KB/recipes/hgrd.aspx

September 10, 2008