0% found this document useful (0 votes)
69 views

Computation Geometry Algorithm Library Form Texas A & M

The document describes the Computational Geometry Algorithms Library (CGAL), which provides efficient and reliable geometric algorithms and data structures implemented as C++ libraries. CGAL offers core algorithms and data structures for computational geometry problems like convex hulls, Delaunay triangulations, and Voronoi diagrams. It also includes support libraries for number types, kernels, and visualization. CGAL aims to make geometric computation easy to use, efficient, and reliable for developers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Computation Geometry Algorithm Library Form Texas A & M

The document describes the Computational Geometry Algorithms Library (CGAL), which provides efficient and reliable geometric algorithms and data structures implemented as C++ libraries. CGAL offers core algorithms and data structures for computational geometry problems like convex hulls, Delaunay triangulations, and Voronoi diagrams. It also includes support libraries for number types, kernels, and visualization. CGAL aims to make geometric computation easy to use, efficient, and reliable for developers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Computational Geometry Algorithms Library

http://parasol.tamu.edu
•  Find the closest emergency phone on campus?
•  How I can go from HRBB to Reed arena?

http://parasol.tamu.edu/CampusNavigator/
•  Find the closest emergency phone on campus?
•  How I can go from HRBB to Reed arena?
•  I want go to HEB, but I don't have car, what I
need to do?
•  Is the marked point inside
of the polygon?
Computational Geometry
•  A branch of computer science devoted to the
study of algorithms which can be stated in
terms of geometry.[1]

•  Systematic study of algorithms and data


structures for geometric objects, with a focus
on exact algorithms that are asymptotically
fast.[2]

1. http://en.wikipedia.org/wiki/Computational_geometry
2. http://www.cs.uu.nl/geobook/
Applications of Computational
Geometry
•  Computer Graphics
•  Computer-Aided Design and http://irrlicht.sourceforge.net/

Manufacturing
http://www.gsd.harvard.edu/inside/

•  Robotics cadcam/

•  Geographic Information
Systems
•  Integrated Circuit design http://en.wikipedia.org/

•  Computer-Aided
Engineering
Convex Hull
Convex Hull
Convex Hull
Triangulation
Triangulation
Delaunay Triangulation
Delaunay Triangulation
Delaunay Triangulation
Voronoi diagram
Voronoi diagram
Voronoi diagram
CGAL (Computational Geometry
Algorithms Library)
  The goal of CGAL Open Source project, is to
provide easy access to efficient and reliable
geometric algorithms in the form of C++
libraries.
  Offers data structures and algorithms, all of
these operate on geometric objects like points
and segments, and perform geometric tests on
them.

http://www.cgal.org/
Structure of CGAL

Basic Library
Algorithm and Data Structures
Support
Library

Kernel Visualization
Geometric Objects File
Geometric Operations I/O
NumberTypes
Generators
...
Core Library
Configurations, assertions, ...

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Kernel
  Elementary geometric objects
  Elementary computation of them

  Primitives 2D, 3D, dD


  Point, Vector, Triangle, Iso_Rectangle,Circle, …
  Predicates
  Comparison, Orientation, InSphere, …
  Constructions
  Intersection, square distance, ...
http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
Kernel and NumberTypes
  Cartesian   Homogeneous
representation representation
Point: (x,y) Point: (hx,hy,hw)

CGAL::Cartesian<FT> CGAL::Homogeneous<RT>
double, Quotient<Gmpz>, int, Gmpz, double
leda_real
typedef double NumberType;
typedef Cartesian< NumberType > Kernel;
typedef Kernel::Point_2 Point;

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
Kernel and NumberTypes
typedef CGAL::Cartesian<NT> Kernel;
NT sqrt2 = sqrt( NT(2) );
Kernel::Point_2 p(0,0), q(sqrt2,sqrt2);
Kernel::Circle_2 C(p,2);
assert( C.has_on_boundary(q) );

Assertion if NT doesn't gives an exact sqrt

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Predicates & Constructions

Predicates Constructions
s
r
r

r
q

Orientation in_circle Intersection circumcenter

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Basic Library

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Basic Library
  Convex Hull (5 alg. In 2D and 3 alg. In 3D)
  2D/3D Triangle/Tetrahedron based data-
structure
  2D/3D Delaunay triangulation
  2D/3D Regular Triangulation
  2D Voronoi Diagram
  2D Meshes

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Basic Library
  Polyhedra data-structure
  Half-edge
  Polyhedral surface
  2D Nef polygons
  3D Nef polyhedra
  Geometric Optimizations
  Smallest enclosing circle and ellipse in 2D
  Smallest enclosing sphere in dD
  Largest empty rectangle
  ...
http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Basic Library
  Line segments or polylines
  Search structures
  Range-tree, Segment-tree,kD-tree
  Window query
  Approximate nearest neighbors
  ...

http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
Installation prerequisites
  Compilers
  GNU g++ 4.0, 4.1, 4.2, 4.3
  MS Visual C++ 8.0, 9.0
  cmake: a cross-platform ``makefile
generator'' (http://www.cmake.org/)
  Boost Library: (http://www.boost.org/ or http://
www.boostpro.com/products/free for Windows
installer)
Prerequisites
Optional
  GMP+MPFR and LEDA: Exact arithmetic
(http://gmplib.org/, http://www.mpfr.org/, http://
www.algorithmic-solutions.com/leda/)
  Visualization
  Trolltech's cross-plaform GUI toolkits Qt3 or
Qt4
  Geomview
Installation
  The CGAL library can be downloaded from
http://www.cgal.org/download.html

  Unpack source code:


tar xzf CGAL-3.8.tar.gz
  Windows installer: CGAL-3.8-Setup.exe

  CGAL manual must be downloaded separately


from http://www.cgal.org/download.html
Directories
  config: configuration files for install script
  cmake/modules: modules for finding and
using libraries
  demo: demo programs (most of them need
QT, geomview or other third-party products)
  doc_html: Installation documentation (HTML)
  examples: example programs
  Include: header files
  scripts: some useful scripts (e.g. for creating
CMakeLists.txt files)
Configure and Build CGAL
  Using cmake GUI
cd CGAL-3.8
cmake-gui .
make
  Using cmake command line

cd CGAL-3.8
cmake .
make
Installing CGAL
  After configure and build
make install
  By default: /usr/local

  Change CMAKE_INSTALL_PREFIX to the


preferred location to install
Compile examples
  Compile the demos and examples
cd examples/Core
cmake .
make
  To generate verbose makefile (show executed

command) use
cmake -DCMAKE_VERBOSE_MAKEFILE=ON .
Simple example
#include <iostream>

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>

#include <CGAL/convex_hull_2.h>
#include <vector>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

typedef K::Point_2 Point_2;

int main() {

Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5),


Point_2(4,1) };

std::vector<Point_2> result;

CGAL::convex_hull_2( points, points+5, std::back_inserter(result) );

std::cout << result.size() << " points on the convex hull\n";

return 0;

}
Compile simple example
  Without cmake:
g++ -frounding-math -O3
-o simple_example -lCGAL
simple_example.cpp
  Using cmake:

  Create CmakeLists.txt file using CGAL-3.8/scripts/


cgal_create_cmake_script
  cmake .
  make simple_example
Timing your experiments
  Dedicated machine, minimal background processes
  Measure “wallclock” time

  ctime
  gettimeofday
  PAPI counters
  ...
  Measure within clock resolution
  Average multiple executions

  Choose appropriate input size range

  Use optimization level -O3

https://parasol.tamu.edu/people/amato/Courses/620/cgal/simple-cgal-demo.tgz
Determine number of iterations
Confidence interval
  m: number of samples (iterations)
  : sample mean
  s: sample standard deviation
  r: tolerance/accuracy (e.g., 0.05)
  z: confidence coefficient (95% is 1.96)
  Conditional (require compute mean, s and m on each
iteration):

While continue iterating

  Precomputed (require compute a et of initial samples):


Timing your experiments
// Computes the difference between two times. Result in seconds
double diff_time(timeval t0, timeval t1) {
return (t1.tv_sec-t0.tv_sec) + (double(t1.tv_usec-t0.tv_usec)/1000000);
}
int main(int argc, char const **argv) {
// Initialize set of points
….
timeval t0,t1;
double elapse = 0;
for(int i=0; i < num_iter; ++i) {
gettimeofday(&t0,NULL);
CGAL::convex_hull_2( points.begin(), points.end(), std::back_inserter(result) );
gettimeofday(&t1,NULL);
elapse += diff_time(t0,t1);
}
std::cout << result.size() << " points on the convex hull in " << (elapse/num_iter) << " sec" << std::endl;
Finding Big-O constant
A function T(n) is O(F(n)) if for some constant c and for all
values of n greater than some value

Where T(n) is the exact complexity (execution time) for


the input size n

Experimentally determining c and n0


•  Let F(n) be the asymptotic complexity and let T(n) be the
measured time of your algorithm
•  Run experiments for a wide range of values of n and plot T(n)/F
(n) versus n. The value of n where T(n)/F(n) levels off is n0 and the
y value that it converges to is the constant c
Finding Big-O constant
Example: computing ratio of expected time F(n)
and measured time T(n)
n time (sec) T(n)/F(n)

100 1.84E-006 1.8435E-008

1000 8.38E-006 8.3787E-009

10000 7.51E-005 7.5094E-009

100000 0.000736748 7.36748E-009

1000000 0.00757946 7.57946E-009


Finding Big-O constant
Example: graphically computing c and n0

c
More information
•  CSCE-620 Computational Geometry
http://parasol.tamu.edu/people/amato/Courses/620/

•  CGAL
–  Tutorials: http://www.cgal.org/Tutorials/
–  Manuals: http://www.cgal.org/Manual/
–  Videos: http://www.cgal.org/videos.html

You might also like