1 / 42

Computational Geometry Algorithms Library

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?

taya
Download Presentation

Computational Geometry Algorithms Library

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computational Geometry Algorithms Library http://parasol.tamu.edu

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

  3. 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?

  4. 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/

  5. Applications of Computational Geometry • Computer Graphics • Computer-Aided Design and Manufacturing • Robotics • Geographic Information Systems • Integrated Circuit design • Computer-Aided Engineering http://irrlicht.sourceforge.net/ http://www.gsd.harvard.edu/inside/cadcam/ http://en.wikipedia.org/

  6. Convex Hull

  7. Convex Hull

  8. Convex Hull

  9. Triangulation

  10. Triangulation

  11. Delaunay Triangulation

  12. Delaunay Triangulation

  13. Delaunay Triangulation

  14. Voronoi diagram

  15. Voronoi diagram

  16. Voronoi diagram

  17. 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/

  18. Structure of CGAL Basic Library Algorithm and Data Structures Support Library Visualization File I/O NumberTypes Generators ... Kernel Geometric Objects Geometric Operations Core Library Configurations, assertions, ... http://www.loria.fr/~lazard/CGAL/2004/intro.pdf

  19. 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

  20. Homogeneous representation Point: (hx,hy,hw) CGAL::Homogeneous<RT> int, Gmpz, double Kernel and NumberTypes • Cartesian representation Point: (x,y) CGAL::Cartesian<FT> double, Quotient<Gmpz>, leda_real typedef doubleNumberType; typedef Cartesian< NumberType > Kernel; typedef Kernel::Point_2 Point; http://www.loria.fr/~lazard/CGAL/2004/intro.pdf

  21. 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

  22. CGAL Predicates & Constructions Predicates Constructions s r r p r q Orientation in_circle Intersection circumcenter http://www.loria.fr/~lazard/CGAL/2004/intro.pdf

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

  24. 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

  25. 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

  26. 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

  27. 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)

  28. 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

  29. 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

  30. 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) • src: source files

  31. Configure and Build CGAL • Using cmake GUI cd CGAL-3.8 cmake-gui . make • Using cmake command line cd CGAL-3.8 cmake . make

  32. Installing CGAL • After configure and build make install • By default: /usr/local • Change CMAKE_INSTALL_PREFIX to the preferred location to install

  33. 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 .

  34. 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; }

  35. 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

  36. 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

  37. 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):

  38. 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;

  39. 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

  40. Finding Big-O constant Example: computing ratio of expected time F(n) and measured time T(n)

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

  42. 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

More Related