4. Computational geometry

Brock University
COSC 3P98 Computer Graphics
Instructor: Brian J. Ross




Basic 2D Geometry Review


2D geometry: intersection of line segments

x = xa + ta (xb - xa)
y = ya + ta (yb - ya)

x = xc + tb (xd - xc)
y = yc + tb (yd - yc)

(0 <= t <= 1 )


2D Geometry: misc


2D geom: Finding interior points of a triangle


Computational geometry


Convex Hull


Convex hull

d = {+,-}( ax1 + by1 + c) / sqrt(a*a+b*b)


Convex Hull


A. Convex Hull: naive (greedy) algorithm

B. Convex Hull: divide and conquer ("Quick Hull")

Quick_Hull_Top (P; P1, P2): { set of points P, points P1, P2}

   Find point with maximum d value >= 0 from line (P1, P2) 
     - if no point exists with d > 0,  
     then find one with d=0 that lays between P1 and P2 
    (ie. its X, Y coordinates are between those of P1 and P2)
   --> call it Pmax

   if no such point 
      then add edge (P1, P2) to convex hull

      else recurse: { 
         Quick_Hull_Top(P; P1, Pmax)
         Quick_Hull_Top(P; Pmax, P2)
}
P1 = (a point with minimum X coord),
P2 = (a point with maximum X coord)
Quick_Hull_Top(P; P1, P2)
Quick_Hull_Bottom(P; P1, P2)


Convex hull algorithm complexity


Planar Triangulation


A. Greedy (Naive) Triangulation

  1. Create an Edge_List of all possible edges from points in P (there are nC2 = n(n-1) / 2 of them)
  2. Initialize triangulation edge set Tri_Edges to empty
  3. For each Ei in Edge_List (i = 1, 2, 3, ...)
  4. Create triangle data structures from this table of edges
    and sort edges in increasing order of edge length: --> TriEdges


B. Trisection Triangulation Algorithm (divide & conquer)

  1. Compute convex hull for points P
  2. Take a random interior point Q, and divide the hull polygon into triangles
  3. For each triangle Ti created:


B. Trisection (cont)


C. Triangulation cleanup algorithm


Example screendumps


Triangulation algorithm complexity


Polygon definitions


Triangulating a simple polygon


Application to 3D geometry


Voronoi diagrams


References:



Back to COSC 3P98 index

COSC 3P98 Computer Graphics
Brock University
Dept of Computer Science
Copyright © 2021 Brian J. Ross (Except noted figures).
http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/comp_geom/
Last updated: October 18, 2021