Geometric Computing: Introduction To CGAL - Fu-berlin.de

Transcription

Geometric Computing: Introduction to CGALPanos Giannopoulos, Dror AtariahAG TIWS 2012/13

!! Register in Campus Management !!

OutlineWhat you need to knowWhat is the course about?Course structureLet’s start!Exercise 1,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/133

You need to know (or learn quickly)ÉC (templates, STL iterators, containers, generic algorithms,etc.)template class InputIterator, class T InputIterator find( InputIterator first, InputIterator last, const T& value );orstd::vector int v;.for(std::vector int ::iterator it v.begin(); it ! v.end(); it) {.}ÉAlgorithms (run-time analysis, O-notation, basic algorithmictechniques and data structures, etc.)ÉBasic geometry,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/134

This course is aboutÉComputing with geometric objects (points, lines, segments,curves, planes, etc.)ÉImplementing and using geometric algorithms and datastructures (efficiently and correctly)ÉUsing the Computational Geometry Algorithms Library (CGAL)(together with STL, Boost, Qt, etc.)É Basic packages: Convex Hull, Arrangements,Triangulations, Voronoi Diagrams, etc.ÉHaving Fun!,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/135

This course is about (for example)intersection pointArrangement cellquery point,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/136

This course is about (for example)ÉBounding VolumesÉTriangulationsÉSurface Reconstruction,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/137

Course structureÉLectures: 19, 26 Oct., 2 Nov., then every second weekÉBe present in the lectures!ÉBring your laptopÉOne concept, package, algorithm per lecture (approximately).Then we’ll work on exercisesÉExercises will gradually become more involved.By the end of Nov. - beginning Dec. each team should choosesome projectÉMake teams of 1-3 peopleÉSuggestion of projects also welcome!ÉYou’ll be graded for the project,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/138

Let’s start!Let’s start!(Many thanks to Efi Fogel from TAU, IL, for sharing thenext slides),FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/139

Geometric computing([E. Fogel, TAU, IL, 2012])Geometric Computing: The Goal(Re)design and implement geometric algorithms and data structures thatare at once certified and efficient in rlin, GeometricComputing:Introductionto CGAL, WS 2012/133,10

Geometric computing([E. Fogel, TAU, IL, 2012])Geometric Computing: The AssumptionsInput data is in general positionDegenerate input, e.g., three curves intersecting at a common point, isprecluded.Computational model: the real RAMOperations on real numbers yield accurate results.Each basic operation on a small (constant-size) set of simple objectstakes unit , GeometricComputing:Introductionto CGAL, WS 2012/134,10

Geometric computing([E. Fogel, TAU, IL, 2012])Geometric Computing: The ProblemsThese assumptions often do not hold in practiceDegenerate input is commonplace in practical applications.Numerical errors are inevitable while using standard computerarithmetic.Naive use of floating-point arithmetic causes geometric programs to:Crash after invariant violationEnter an infinite loopProduce wrong outputThere is a gap between Geometry in theory and Geometry withfloating-point arithmetic.Standard cs-theory asymptotic performance measures many times poorpredictors of practical UBerlin, GeometricComputing:Introductionto CGAL, WS 2012/135,10

Geometric computing([E. Fogel, TAU, IL, 2012])Geometry in Theory pxorientation(p, q, r ) sign det qxrxpyqyry 1 0 cw(p, q, r )1 0 colinear(p, q, r ) 1 0 ccw(p, q, r ) sign((qx px )(ry py ) (qy py )(rx px ))ccw(p, q, s) ccw(s, q, r ) ccw(p, s, r ) ccw(p, q, r , GeometricComputing:Introductionto CGAL, WS 2012/136,10

Geometric computing([E. Fogel, TAU, IL, 2012])Geometry in Practice: Trouble with Doubleorientation(p, q, r ) sign((qx px )(ry py ) (qy py )(rx px ))256 256 pixel imagex yr (24, 24)q(12, 12)(0.5, 0.5)p(0.5 x · ǫ, 0.5 y · ǫ)0 x, y 256, ǫ 2 53Positive Zero Negative[KMP 08]ComputationalGeometryAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/137,10

Geometric computing([E. Fogel, TAU, IL, 2012])The Naive Solution: Exact Multi-Precision ArithmeticImplemented for several number types:Integers, rational (e.g., GMP, CORE, and LEDA)Even algebraic numbers (e.g., CORE and LEDA)No solution for transcendental numbers!Exact up to memory limit.Slow running , GeometricComputing:Introductionto CGAL, WS 2012/138,10

Geometric computing([E. Fogel, TAU, IL, 2012])The Efficient Solution: Exact Geometric ComputationEnsure that the control flow in the implementation corresponds to thecontrol flow with exact arithmetic.[Yap04]Evaluate predicate instantiated with limited precision.If uncertain evaluate predicate instantiated with multipleprecision.orientation(p, q, r ) 0ComputationalGeometryAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/13 0 09,10

Geometric computing([E. Fogel, TAU, IL, 2012])Floating-Point ArithmeticA double float f uses 64 bits1 bit for the sign s.52 bits for the mantissa m m1 . . . m52 .11 bits for the exponent e e1 . . . e52 .f 1s · (1 Σ1 i 52 mi 2 i ) · 2e 2013 , if 0 e 211 1.NotationFor a R, let fl(a) denote the closest float to a.For a Z, a fl(a) ǫ fl(a) , where ǫ 2 53 .For o { , , }, f1 õf2 ǫ f1 õf2 .Floating-point arithmetic is monotone.e.g., b c a b a c.FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13,10

Geometric computing([E. Fogel, TAU, IL, 2012])Geometric-Computing BibliographyLutz Kettner, Kurt Mehlhorn, Sylvain Pion, Stefan Schirra, and Chee K. Yap.Classroom Examples of Robustness Problems in Geometric Computations.Computational Geometry: Theory and Applications, 40(1):61–78, 2008.Chee K. Yap.Robust geomtric computation.In Jacob E. Goodman and Joseph O’Rourke, editors, Handbook of Discrete and Computational Geometry, chapter 41,pages 927–952. Chapman & Hall/CRC, Boca Raton, FL, 2n d edition, 2004.Kurt Mehlhorn and Stefan Näher.Leda: A Platform for Combinatorial and Geometric Computing.Cambridge University Press, Cambridge, UK, , GeometricComputing:Introductionto CGAL, WS 2012/1313,10

Generic programming([E. Fogel, TAU, IL, 2012])Generic Programming ParadigmDefinition (Generic Programming)A discipline that consists of the gradual lifting of concrete algorithmsabstracting over details, while retaining the algorithm semantics LibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1314,11

Generic programming([E. Fogel, TAU, IL, 2012])Generic Programming ParadigmDefinition (Generic Programming)A discipline that consists of the gradual lifting of concrete algorithmsabstracting over details, while retaining the algorithm semantics andefficiency.[MS88]Translation:You do not want to write the same algorithm again and again !ComputationalGeometryAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1315,11

Generic programming([E. Fogel, TAU, IL, 2012])Generic Programming ParadigmDefinition (Generic Programming)A discipline that consists of the gradual lifting of concrete algorithmsabstracting over details, while retaining the algorithm semantics andefficiency.[MS88]Translation:You do not want to write the same algorithm again and again ! You even want to make it independent from the used types.See also: http://en.wikipedia.org/wiki/Generic Berlin, GeometricComputing:Introductionto CGAL, WS 2012/1316,11

Generic programming([E. Fogel, TAU, IL, 2012])Terms and DefinitionsClass Template A specification for generating (instantiating) classes basedon parameters.Function Template A specification for generating (instantiating) functionsbased on parameters.Template ParameterSpecialization A particular instantiation from a template for for a givenset of template Berlin, GeometricComputing:Introductionto CGAL, WS 2012/1317,11

Generic programming([E. Fogel, TAU, IL, 2012])Generic Programming DictionaryConcept A set of requirements that a class must fulfill.Model A class that fulfills the requirements of a concept.Traits Models that describe behaviors.Refinement An extension of the requirements of another concept.Generalization A reduction of the requirements of another lin, GeometricComputing:Introductionto CGAL, WS 2012/1318,11

Generic programming([E. Fogel, TAU, IL, 2012])Some Generic Programming LibrariesStl The C Standard Template Library.Boost A large set of portable and high quality C libraries thatwork well with, and are in the same spirit as, the C Stl.Leda The Library of efficient data types and algorithms.Cgal The computational geometry algorithms and data braryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1319,11

Generic programming([E. Fogel, TAU, IL, 2012])Stl ComponentsContainer A class template, an instance of which stores collection ofobjects.Iterator Generalization of pointers; an object that points to anotherobject.AlgorithmFunction Object (Functor) A computer programming construct invoked asthough it were an ordinary function.Adaptor A type that transforms the interface of other types.Allocator An objects for allocating n, GeometricComputing:Introductionto CGAL, WS 2012/1320,11

Generic programmingtemplate class InputIterator, class T InputIterator find( InputIterator first, InputIterator last, const T& value );orstd::vector int v;.for(std::vector int ::iterator it v.begin(); it ! v.end(); it) {.},FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/1312

Generic programming([E. Fogel, TAU, IL, 2012])Generic AlgorithmsA generic algorithm has 2 parts:The actual instructions that describe the steps of the algorithm.A set of requirements that specify which properties its argument typesmust satisfy.,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/1313

Generic programming([E. Fogel, TAU, IL, 2012])A Trivial Example: swap ( ) t e m p l a t e typename T v o i d swap (T& a , T& b ){ T tmp ( a ) ; a b ; b tmp ; } When a function call is compiled the function template is instantiated. The template parameter T is substituted with a data type.The data type must have12a copy constructor, andan assignment rlin, GeometricComputing:Introductionto CGAL, WS 2012/1322,13

Generic programming([E. Fogel, TAU, IL, 2012])A Trivial Example: swap ( ) t e m p l a t e typename T v o i d swap (T& a , T& b ){ T tmp ( a ) ; a b ; b tmp ; } When a function call is compiled the function template is instantiated. The template parameter T is substituted with a data type.The data type must have12a copy constructor, andan assignment operator.In formal words:T is a model of the concept CopyConstructible.T is a model of the concept Berlin, GeometricComputing:Introductionto CGAL, WS 2012/1323,13

Generic programming([E. Fogel, TAU, IL, 2012])A Trivial Example: swap ( ) t e m p l a t e typename T v o i d swap (T& a , T& b ){ T tmp ( a ) ; a b ; b tmp ; } When a function call is compiled the function template is instantiated. The template parameter T is substituted with a data type.The data type must have12a copy constructor, andan assignment operator.In formal words:T is a model of the concept CopyConstructible.T is a model of the concept Assignable. The i n t data type is a model of the 2 concepts. i n t a 2 , b 4 ; s t d : : swap ( a , b ) ;ComputationalGeometryAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1324,13

Generic programming([E. Fogel, TAU, IL, 2012])ConceptA concept is a set of requirements divided into four Berlin, GeometricComputing:Introductionto CGAL, WS 2012/1325,13

Generic programming([E. Fogel, TAU, IL, 2012])ConceptA concept is a set of requirements divided into four categories:Associated Types — auxiliary types, for exampleP o i n t 2 — a type that represents a two-dimensional n, GeometricComputing:Introductionto CGAL, WS 2012/1326,13

Generic programming([E. Fogel, TAU, IL, 2012])ConceptA concept is a set of requirements divided into four categories:Associated Types — auxiliary types, for exampleP o i n t 2 — a type that represents a two-dimensional point.Valid Expressions — C expressions that must compile successfully, forexamplep q, where p and q are objects of type P o i n t 2 .ComputationalGeometryAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1327,13

Generic programming([E. Fogel, TAU, IL, 2012])ConceptA concept is a set of requirements divided into four categories:Associated Types — auxiliary types, for exampleP o i n t 2 — a type that represents a two-dimensional point.Valid Expressions — C expressions that must compile successfully, forexamplep q, where p and q are objects of type P o i n t 2 .Runtime Characteristics — characteristics of the variables involved inthe valid expressions that apply during the variables’ yAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1328,13

Generic programming([E. Fogel, TAU, IL, 2012])ConceptA concept is a set of requirements divided into four categories:Associated Types — auxiliary types, for exampleP o i n t 2 — a type that represents a two-dimensional point.Valid Expressions — C expressions that must compile successfully, forexamplep q, where p and q are objects of type P o i n t 2 .Runtime Characteristics — characteristics of the variables involved inthe valid expressions that apply during the variables’ lifespans,pre/post-conditions.Complexity Guarantees — maximum limits on the computing resourcesconsumed by the valid UBerlin, GeometricComputing:Introductionto CGAL, WS 2012/1329,13

Generic programming([E. Fogel, TAU, IL, 2012])Generic Programming & the Stl BibliographyAndrei Alexandrescu.Modern C Design: Generic Programming And Design Patterns Applied.Addison-Wesley, Boston, MA, USA, 2001.Matthew H. Austern.Generic Programming and the Stl.Addison-Wesley, Boston, MA, USA, 1999.Erich Gamma, Richard Helm, Ralph Johnson, and John M. Vlissides.Design Patterns — Elements of Reusable Object-Oriented Software.Addison-Wesley, Boston, MA, USA, 1995.David R. Musser, Gillmer J. Derge, and Atul Saini.Stl tutorial and reference guide: C programming with the standard template library.Addison-Wesley, Boston, MA, USA, 2nd edition, Professional Computing Series, 2001.David Vandevoorde and Nicolai M. Josuttis.C Templates: The Complete Guide,Addison-Wesley, Boston, MA, USA, 2002.Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine.The Boost Graph Library,Addison-Wesley, Boston, MA, USA, 2002.David A. Musser and Alexander A. Stepanov.Generic programming.In Proceedings of International Conference on Symbolic and Algebraic Computation, volume 358 of LNCS, pages 13–25.Springer, 1988.The planned new standard for the C programming language.http://en.wikipedia.org/wiki/C 0x#References .The Sgi STL.http://www.sgi.com/tech/stl/ .,ComputationalGeometryAlgorithmLibraryFUBerlin, GeometricComputing:Introductionto CGAL, WS 2012/133013

CGAL([E. Fogel, TAU, IL, 2012])Cgal: Mission“Make the large body of geometric algorithms developed in the field ofcomputational geometry available for industrial applications”Cgal Project Proposal, 1996Computational Geometry Algorithm LibraryFU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/133114,

CGAL([E. Fogel, TAU, IL, 2012])Some of Cgal ContentBounding VolumesPolyhedral cationArrangementsBoolean OperationsVoronoi DiagramsParametrisationStreamlinesMesh GenerationRidge Detection Neighbor SearchIntersection Detection Minkowski SumsComputational Geometry Algorithm LibraryFU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13PCAKinetic Data StructuresPolytope DistanceQP Solver3214,

CGAL([E. Fogel, TAU, IL, 2012])Cgal FactsWritten in C Follows the generic programming paradigmDevelopment started in 1995Active European sites:1INRIA Sophia Antipolis2MPII Saarbrücken3Tel Aviv University4ETH Zürich (Plageo)5University of Crete and FO.R.T.H.6INRIA Nancy7Université Claude Bernard de Lyon8ENS Paris9University of Eindhoven10University of California, San Francisco11University of AthensComputational Geometry Algorithm LibraryFU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/133414,

CGAL([E. Fogel, TAU, IL, 2012])Cgal in Numbers900,00010,0003,5003,0001,0001206025672lines of C codedownloads per year not including Linux distributionsmanual pagessubscribers to cgal-announce listsubscribers to cgal-discuss listpackagescommercial usersactive developersmonths release cycleGoogle’s page rank for cgal.org.comlicenses: Open Source and commercialComputational Geometry Algorithm LibraryFU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/133614,

CGAL([E. Fogel, TAU, IL, 2012])Cgal PropertiesReliabilityExplicitly handles degeneraciesFollows the Exact Geometric Computation (EGC) paradigmFlexibilityIs an open libraryDepends on other libraries (e.g., Boost, Gmp, Mpfr, Qt, & Core)Has a modular structure, e.g., geometry and topology are separatedIs adaptable to user codeIs extensible, e.g., data structures can be extendedEase of UseHas didactic and exhaustive ManualsFollows standard concepts (e.g., C and Stl)Characterizes with a smooth learning-curveEfficiencyAdheres to the generic-programming paradigm Polymorphism is resolved at compile timeComputational Geometry Algorithm Library38,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/1314

CGAL([E. Fogel, TAU, IL, 2012])Cgal StructureBasic LibraryAlgorithms and Data Structurese.g., Triangulations, Surfaces, and ArrangementsVisualizationFilesI/OKernelElementary geometric objectsElementary geometric computations on themNumber TypesGenerators.Support LibraryConfigurations, Assertions,.,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1439

CGAL([E. Fogel, TAU, IL, 2012])Cgal Kernel ConceptGeometric objects of constant size.Geometric operations on object of constant size.Primitives 2D, 3D, dDpointvectortriangleiso omparisonintersectionorientationsquared distancecontainment . . .,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1540

CGAL([E. Fogel, TAU, IL, 2012])Cgal Kernel Affine Geometrypoint - originpoint - pointpoint vector vector vector pointpoint point Illegalmidpoint(a, b) a 1/2 (b a),FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1641

CGAL([E. Fogel, TAU, IL, 2012])Cgal Kernel ClassificationDimension: 2, 3, arbitraryNumber types:Ring: , , Euclidean ring (adds integer division and gcd) (e.g., CGAL : : Gmpz).Field: , , ,/ (e.g., CGAL : : Q u o t i e n t (CGAL : : Gmpz ) ).Exact sign evaluation for expressions with roots ( F i e l d w i t h s q r ).Coordinate representationCartesian — requires a field number type or Euclidean ring if noconstructions are performed.Homegeneous — requires Euclidean ring.Reference countingExact, Filtered,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1642

CGAL([E. Fogel, TAU, IL, 2012])Cgal Kernels and Number TypesCartesian representationHomogeneous representationhxhxx hwhypointpointhyy hwhwIntersectionoftwolines a1 x b 1 y c 1 0a1 hx b1 hy c1 hw 0a2 x b 2 y c 2 0a2 hx b2 hy c2 hw 0(x, y ) b1 b2 a1a2c1c2b1b2a1a2, a1a2c1c2b1b2Field operations (hx, hy , hw ) b1b2c1c2, a1a2c1c2,a1a2b1b2 Ring operations,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1643

CGAL([E. Fogel, TAU, IL, 2012])Example: K e r n e l s NumberType C a r t e s i a n FieldNumberType t y p e d e f CGAL : : C a r t e s i a n Gmpq K e r n e l ;t y p e d e f CGAL : : S i m p l e c a r t e s i a n d o u b l e K e r n e l ; No reference-counting, inexact instantiationHomogeneous RingNumberType t y p d e f CGAL : : Homogeneous Core : : B i g I n t K e r n e l ;d-dimensional C a r t e s i a n d and Homogeneous dTypes OperationsK e r n e l : : P o i n t 2 , K e r n e l : : Segment 3Kernel : : Less xy 2, Kernel : : Construct bisector 3,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1644

CGAL([E. Fogel, TAU, IL, 2012])Cgal Numerical Issues t y p e d e f CGAL : : C a r t e s i a n NT K e r n e l ;NT s q r t 2 s q r t (NT ( 2 ) ) ;Kernel : : Point 2 p (0 ,0) , q( sqrt2 , sqrt2 ) ;K e r n e l : : C i r c l e 2 C( p , 4 ) ; a s s e r t (C . h a s o n b o u n d a r y ( q ) ) ;OK if NT supports exact sqrt.Assertion violation otherwise.,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1645

CGAL([E. Fogel, TAU, IL, 2012])Computing the Intersection typedef Kernel : : Line 2 Line 2 ;i n t main ( ) {Kernel kernel ;P o i n t 2 p ( 1 , 1 ) , q ( 2 , 3 ) , r ( 12 ,19);Line 2 l1 (p , q ) , l2 ( r , p ) ;i f ( d o i n t e r s e c t ( l1 , l 2 )) {CGAL : : O b j e c t o b j CGAL : : i n t e r s e c t i o n ( l 1 , l 2 ) ;i f ( c o n s t P o i n t 2 p o i n t o b j e c t c a s t P o i n t 2 (&o b j ) ) {/ do s o m e t h i n g w i t h p o i n t /} e l s e i f ( c o n s t Segment 2 s e g m e n t o b j e c t c a s t Segment 2 (&o b j ) ) {/ do s o m e t h i n g w i t h s e g m e n t /}}return 0;},FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1649

CGAL([E. Fogel, TAU, IL, 2012])Cgal Basic LibraryGeneric data structures are parameterized with TraitsSeparates algorithms and data structures from the geometric kernel.Generic algorithms are parameterized with iterator rangesDecouples the algorithm from the data structure.,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1650

CGAL([E. Fogel, TAU, IL, 2012])Cgal BibliographyA. Fabri, G.-J. Giezeman, L. Kettner, S. Schirra, and S. Schönherr.On the design of Cgal a computational geometry algorithms library.Software — Practice and Experience, 30(11):1167–1202, 2000. Special Issue on Discrete Algorithm Engineering.A. Fabri and S. Pion.A generic lazy evaluation scheme for exact geometric computations.In 2nd Library-Centric Software Design Workshop, 2006.M. H. Overmars.Designing the computational geometry algorithms library Cgal.In Proceedings of ACM Workshop on Applied Computational Geometry, Towards Geometric Engineering, volume 1148,pages 53–58, London, UK, 1996. Springer.The Cgal Project.Cgal User and Reference Manual.Cgal Editorial Board, 3.9 edition, 2010. http://www.cgal.org/Manual/3.9/doc html/cgal manual/contents.html .Efi Fogel, Ron Wein, and Dan Halperin.Cgal Arrangements and Their Applications, A Step-by-Step Guide.Springer, 2012.,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/13Computational Geometry Algorithm Library1651

Exercise 11. Install CGAL: www.cgal.org(Installation tips also on the course’s website)2. Read CGAL’s manual: Chapters 1 (Introduction), 2 (Preliminaries),3 (Installation), 5 (Number Types), 11 (2D and 3D Geometry Kernel)3. For the following use the Cartesian kernel with number type double.Use only geometric primitives from the kernel. Do not use any kerneloperation (predicate or construction).ÉÉÉÉWrite a function that takes two segments in the plane asarguments and returns: 1 if the segments intersect, 0 if theydon’t.Write a function that takes two segments in the plane asarguments and computes their intersection (if it exists).Write a function that takes a point and a segment in the plane asarguments and returns 1 if the point lies on the segment and 0otherwise.Test your functions.4. Suggested reading: Computational Geometry in C (Second Edition), J.O’Rourke. Cambridge University Press, 1998.,FU Berlin, Geometric Computing: Introduction to CGAL, WS 2012/1317

This course is about É Computing with geometric objects (points, lines, segments, curves, planes, etc.) É Implementing and using geometric algorithms and data structures (efficiently and correctly) É Using the Computational Geometry Algorithms Library (CGAL) (together with STL, Boost, Qt, etc.) É Basic packages: Convex Hull, Arrangements, Triangulations, Voronoi Diagrams, etc.