Computation Geometry Algorithm Library Form Texas A & M
Computation Geometry Algorithm Library Form Texas A & M
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]
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
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) );
http://www.loria.fr/~lazard/CGAL/2004/intro.pdf
CGAL Predicates & Constructions
Predicates Constructions
s
r
r
r
q
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
cd CGAL-3.8
cmake .
make
Installing CGAL
After configure and build
make install
By default: /usr/local
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;
int main() {
std::vector<Point_2> result;
return 0;
}
Compile simple example
Without cmake:
g++ -frounding-math -O3
-o simple_example -lCGAL
simple_example.cpp
Using cmake:
ctime
gettimeofday
PAPI counters
...
Measure within clock resolution
Average multiple executions
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):
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