120 likes | 236 Views
1.4 Exercises (cont.). Definiton: A set S of points is said to be affinely (convex) independent if no point of S is an affine combination of the others.
E N D
1.4 Exercises (cont.) Definiton: A set S of points is said to be affinely (convex) independent if no point of S is an affine combination of the others. Affine (convex) basisBS of a set S is an affinely (convex) independent subset of S such that every point in S is an affine (convex) combination of points from BS. A set A1, A2,…, Ak is affinely independent if and only if the set of vectors A1A2,…, A1Akis linearly independent. Exercise 7
Therefore... Every set in En has an affine basis of k n+1 points. (easy to prove). It has also a convex basis (not easy to prove), which is not necessarily finite. A number of points in an affine basis of a set S is constant and said to be the dimension of S.
Theorem If S is a finite set of points, then Conv (S) is a polygon with the vertices in S. Proof: 1. There is a convex polygon PS with the vertices in S. (for example, Algorithm1) 2. PS= Conv (S).
Algorithm 1. (Convex Hull) - Pseudo code - Input. A set of points in the plane. Output. A list containing the vertices of Conv(P) . 1. Sort the points by (x,y)-coordinate, resulting in a sequence p1,p2, …,pn. 2. Put the points p1 andp2 in the list Lupperwith p1 in the first position. 3. Fori 3 to n 4. do Append pi to Lupper 5. whileLuppercontains more than two points and the last three points in Lupperdo not make a right turn 6. do delete the middle of the last three points from Lupper. 7-11 the same in the opposite direction: pn to p1: Make Llower 12. Remove the first and the last point from Lupper . 13. Append Lupper and Llower to make L. 14. return L.
pi Algorithm 1, Step 5: pi X X X pi pi X X X
Algorithm 1 (cont.) 1 XPi-2 YPi-2 XPi-2 XPi YPi-2 YPi - - 1 XPi-1 YPi-1 • Left – Right decision • Degeneracy • O, O, • The complexity of Algorithm 1 is O(nlogn) Exercise 8= Implementation of Algorithm 1 > = <0 = XPi-1 XPi YPi YPi-1 - - 1 XPi YPi
Algorithm2. (2-dim) (Exercise 9 = Implementation of algorithm 2) Assumption. The points are ordered in a sequence increasingly with respect to the x coordinate. The vertices having the same x coordinate are ordered with respect to the y coordinate middle ones omitted. The algorithm is incremental (inductive), at the step k+1 the (k+1)st point Ak+1, as well as the convex hull of the previous points, are used to produce the convex hull C k of the first k+1-points.
Algorithm2. (2-dim) • Storing data. -Edges (oriented): origin and the pointer to the “next” edge. -Vertices: a point A and the edge AB originated at A. Step k+1. 1. Find the the two vertices of Ck which divide the “visible” and the “invisible” part of Ck with respect to (“from”) the point Ak+1 .
Algorithm2. (2-dim), Step k+1(cont.) Br B1 Ak+1 B0 Bs B m-1x - A k+1x B m-1y - A k+1y [A k+1B m-1 , A k+1B m ] = B m y - A k+1y B m x - A k+1x
Algorithm2. (2-dim), Step k+1(cont.) Denote B0=A k . The vertices B m are obtained recursively so that B m-1B m is the oriented edge of C k and that the 2X2 determinant [A k+1B m-1 , A k+1B m ] is not positive. In another words, the vertices B m are in the visible part of C k . Let B r be the last one in the sequence having negative determinant, i.e. such that the determinant corresponding to B r and the next vertex of C k is not negative. Hence, the vertex B r is one of the two vertices we are looking for. Similarly, starting with B0 we can inductively obtain a sequence of the vertices B m-1with negative indices having the same property. Let B -s be the last vertex in this sequence.
Algorithm2. (2-dim), Step k+1(cont.) 2. Vertices B -s + 1 ,…, B r - 1 are deleted together with the corresponding edges. Vertex A k+1 is added together with the edges B -s A k+1 and A k+1 B r. B r+1 B r+1 B r A k+1 A k+1 B -s B -s
Algorithm2. (2-dim), Step k+1(cont.) 3. If there is the vertex B -s -1 i.e if the points B -s -1 , B -s and A k+1 are collinear, the middle point B -s is omitted and the edges B -s -1 B -s and B -s A k+1 are substituted with B -s -1 A k+1.The same procedure is performed with the vertex B r..