110 likes | 207 Vues
Algorithm3 . (3-dim). ( Exercise 10 = Implementation of algorithm 3 ). Assumptions • Points are ordered in a sequence increasingly with respect to the x coordinate. • Points having the same x coordinate are cleared to the vertices of their convex hull.
E N D
Algorithm3. (3-dim) (Exercise 10 = Implementation of algorithm 3) Assumptions • Points are ordered in a sequence increasingly with respect to the x coordinate. • Points having the same x coordinate are cleared to the vertices of their convex hull. • Algorithm is incremental (inductive): at the step k+1 the (k+1)st point A k+1, as well as the convex hull C k of the previous points, are used to produce the convex hull C k+1 of the first k+1-points.
Algorithm3. (cont.) Storing data of Ck . Edges are oriented, i.e. for each edge we store a pair of oriented edges. For each (oriented) edge e A,B we store: • Coordinates of its origin (A), • Pointer to the opposite edge e B,A, (function Twin(e A,B )), • Pointer to the facet “left of” e A,B (function Left (e A,B )), • Pointer to the edge of this facet which ends at its origin (Prev (e A,B ) ). For each vertex A we store an: • Edge which originates at A. For each facet we store a • Pointer to its edge (appropriately oriented) .
Algorithm3. (Storing data cont.) Out() Example: (XA,YA,ZA) e A,B A A e B,A B (XB,YB,ZB) ... F Origin() Twin() Prev() Left() B G e A,B e B,A e G,A ABG A E e C,D e D,C e B,C C BCDG C D eC,D ... e D,C BCDG ...
Algorithm3. (cont.) Vertex Figure of A: Vertices of the vertex figure: e1=eA,B = Out(A) e2=eA,G =Twin(Prev(e1)) e3=eA,F =Twin(Prev(e2)) e4=eA,E =Twin(Prev(e3)) e5=eA,C =Twin(Prev(e4)) Edges of the vertex figure: Left(e1), Left(e2), Left(e3), Left(e4), Left (e5) A F B G E C D
Algorithm3. (cont.) Step k+1. 1. Find the (space) polygon H k of edges of C k which divide the “visible” and the “invisible” part of C k with respect to (“from”) the point A k+1 . A k+1 A k A 5 X A 2 A 3 A 4 A 1 A 0
Algorithm3. (step k+1 cont.) During the construction of H k, all visible facets, verteces and edges will be deleted except the vertices and edges of H k . 1.1 Start with the vertex figure V k = e 1e 2…e r of A k . A k is the last previously added point, the closest to A k in C k, therefore visible! Starting with the edge e 1 = Out (A k) of C k (a “vertex” of V k) we go counterclockwise (in + direction) around V k and check if the facets (“edges” of V k) are visible. The visibility of the facet with edges e i and e i+1 is checked similarly as in 2 dimensions by the sine of a the mixed product [ e i, e i+1, A kA k+1] ( > 0 visible). ei+1 A k+1 A k ei
Algorithm3. (step k+1 cont.) 1.1.1 All facets in Vk are visible. We delete all these facets, all their edges* and the vertex Ak. The remaining edges of deleted facets are stored in a set Rk**. (At each original edge e A,B, a pointer R (e A,B) to its duplicate in Rk is stored, and vice versa.) ei+1 Rk A k ei * both ± directed edges incident to Ak ** Rk is a cycle of oriented edges. Rk will evolve in Hk !
Algorithm3. (step k+1 cont.) 1.1.2 Some facets in Vk are not visible. We delete all visible facets and all their edges. Now vanish some pairs ± ei (bordering two visible neighbors), some pairs ± ei remain, and vanish exactly two singles (bordering a visible and an invisible neighbor) h1 and h2. Their twins -h1 and -h2 are the first edges of H k, A k the first vertex. The set Rk is defined the same way as in 1.1.1. A k A k ei+1 Rk ei
Algorithm3. (step k+1 cont.) 1.m+1 Inductively, at any vertex X of the cycle R k not already used in some step 1.x., perform a step 1.m+1.1 / 1.m+1.2 similar to the step 1.1.1 / 1.1.2. The visible facets around X and their edges will be deleted. Two (left fig. ) or one (right fig.) edge of R k will be replaced with a sequence of undeleted edges of deleted facets, and the cycle R k will be updated. X X
Algorithm3. (step k+1 cont.) If all the vertices of R k are already visited, then H k = R k 2. Add the edges and the facets which connect A k+1 with the vertices and the edges of H k . A k+1 A k+1 A k A k A 5 A 5 A 2 A 2 A 3 A 3 A 4 A 4 A 1 A 0 A 1 A 0
Algorithm3. (step k+1 cont.) 3. Deal with degeneracy (special cases). If A k+1 is in the plane of some facet f of C k ,we “glue” the corresponding triangles to this facet. f A k+1 A k+1 A k+1 A k+1