SlideShare a Scribd company logo
1 of 43
Accurate, Simple and Efficient
Triangulation of a Polygon
by Ear Removal
with Lowest Memory Consumption
Kasun Ranga Wijeweera
1
Introduction
2
What is a Polygon?
• Let v0, v1, v2…, vn-1 be n points in the plane.
• Let e0 = v0v1, e1 = v1v2…, ei = vivi+1…, en-1 = vn-1v0 be n
segments connecting the points.
• These segments bound a polygon if and only if
1. The intersection of each pair of segments adjacent in the
cyclic ordering is the single point shared between them: ei ∩
ei+1 = vi+1, for all i = 0…, n – 1.
2. Nonadjacent segments do not intersect: ei ∩ ej = Ф, for all j
≠ i + 1.
3. None of three consecutive vertices are collinear.
Note that all index arithmetic are modulo n.
3
Examples of Polygons
4
Examples of Polygons…
5
Triangulation of a Polygon
• Definition: The decomposition of a polygon into a set of non
overlapping triangles.
• Example:
6
Research Problem
• The basic triangulation algorithm can triangulate a polygon in
O (n4) time and O (n2) space with 100% accuracy.
• Even though more efficient algorithms are available in
literature, they are not 100% accurate due to the use of
floating point arithmetic.
• A simple and 100% accurate triangulation algorithm is
proposed with O (n3) time and O (n) space.
7
Literature Survey
8
A Diagonal of a Polygon
• If the intersection of line segment AB with ∂P is exactly the
set {A, B} and the line segment AB is nowhere exterior to the
polygon P then the line segment is called a diagonal of the
polygon.
9
Basic Triangulation Algorithm
• Triangulation Theorem: Every polygon P of n vertices may
be partitioned into triangles by the addition of (zero or more)
diagonals.
• The method suggested by triangulation theorem is an O (n4)
algorithm.
• There are nC2 = O (n2) diagonal candidates.
• Testing each diagonal candidate for diagonalhood costs O (n).
• Repeating this O (n3) computation for each of the n – 3
diagonals yields O (n4).
10
Triangulation Algorithms
• Naïve approach: O (n4)
• Lennes (1911): O (n2)
• Garey et al. (1978): O (n log n)
• Hertel & Mehlhorn (1983): O (n log r), r reflex
• Chazelle & Incerpi (1984): O (n log s), s sinuosity
• Tarjan & Van Wyk (1988): O (n log log n)
• Clarkson et al. (1989): O (n log* n), randomized
• Toussaint (1990): O (n + nt0), t0 int. triangs.
• Kirkpatrick et al. (1990): O (n log* n), bnded. ints.
• Chazelle (1991): O (n)
• Seidel (1991): O (n log* n), randomized
• Amato et al. (2001): O (n), randomized
11
Methodology
12
Related Research Paper
K. R. Wijeweera, S. R. Kodituwakku (2016), Accurate, Simple,
and Efficient Triangulation of a Polygon by Ear Removal
with Lowest Memory Consumption, Ceylon Journal of
Science, Volume 45 (Issue 3), pp. 65-76.
13
An Ear of a Polygon
• Suppose P, Q, and R be three consecutive vertices of a
polygon.
• If PR is a diagonal then PQR is called an ear of the polygon.
14
Representation of the Polygon
• The variable points stores the number of vertices of the
polygon.
• The coordinates of the vertices of the polygon are stored
using two arrays x and y.
• Then (x[i], y[i]) denotes the ith vertex of the polygon where i
= 0, 1…, (points - 1).
15
Two Known Theorems
• Theorem 1: Every polygon of n ≥ 4 vertices has at least two
non-overlapping ears.
• Theorem 2: Every triangulation of a polygon P of n vertices
uses n – 3 diagonals and consists of n – 2 triangles.
16
Vertices = 5
Diagonals = 5 – 3 = 2
Triangles = 5 – 2 = 3
The Order of Vertices of a Triangle
• The vertices of the triangle: P1 (x1, y1), P2 (x2, y2), P3 (x3, y3).
• Let t = x1 * (y2 – y3) + x2 * (y3 – y1) + x3 * (y1 – y2).
• t = 0 ↔ (P1, P2, P3) are collinear.
• t > 0 ↔ (P1, P2, P3) are in anticlockwise order.
• t < 0 ↔ (P1, P2, P3) are in clockwise order.
17
t > 0 t < 0
Identifying the Convex Vertices of the Polygon
• None of three consecutive vertices of the initial polygon are
collinear by the definition of a polygon.
• Therefore, each convex vertex is strictly convex.
• That means, interior angle formed by each convex vertex is
less than π.
• Lemma: The lowest vertex of a polygon is strictly convex.
18
Identifying the Convex Vertices of the Polygon…
• There may be several lowest vertices.
• The function lv returns the index of one of those lowest
vertices.
19
Identifying the Convex Vertices of the Polygon…
• Let’s consider the polygon given below as an example.
• The function lv returns 0.
20
Identifying the Convex Vertices of the Polygon…
• The function ts returns the sign of value t when index of
middle vertex of three consecutive vertices is provided.
• The function isConvex returns 1 if the passed index
corresponds to a convex vertex.
• If ts (v) * ts (lv ()) > 0 then the vertex v and lowest vertex
have the same sign.
• If they have the same sign then vertex v is convex.
21
Identifying an Ear of the Polygon
• An ear should always be with a convex vertex.
• The triangles formed by those convex vertices with their two
neighboring vertices are considered.
• If such a triangle does not contain any of the vertices of the
polygon inside it then that triangle should be an ear.
22
Identifying an Ear of the Polygon…
• The function isEmpty returns 1 if the triangle formed by
vertex v does not contain any of the vertices of the polygon.
• The function tv returns the sign of value t. This saves lots of
computational cost.
• The keyword CONTINUE is used to avoid own three vertices
of the triangle.
IF ((i == v) OR (i == a) OR (i == b))
{
CONTINUE;
}
23
Identifying an Ear of the Polygon…
tsv = tv (v, a, b);
IF ((tsv * tv (v, a, i) ≥ 0) AND (tsv * tv (a, b, i) ≥ 0) AND (tsv *
tv (b, v, i) ≥ 0))
{
RETURN 0;
}
24
Pruning an Ear from the Polygon
• Once an ear was found then the algorithm prunes that ear
from the original polygon.
• This is done by function prune.
VOID prune (INTEGER v)
{
INTEGER i;
points = points - 1;
FOR (i = v TO (points - 1))
{
x[i] = x[i + 1];
y[i] = y[i + 1];
}
} 25
Pruning an Ear from the Polygon…
• The original polygon.
26
Pruning an Ear from the Polygon…
• After pruning one ear.
27
Iterative Process
• After pruning two ears.
28
Iterative Process…
• After pruning three ears.
29
Iterative Process…
• After pruning four ears.
30
Iterative Process…
• After pruning five ears.
31
Iterative Process…
• After pruning six ears.
32
Iterative Process…
• After pruning seven ears.
33
The Triangulated Polygon
• Diagonals = 7; Triangles = 8.
34
Results and Discussion
35
Time Complexity
• Let n be the number of vertices in the given polygon.
• It takes O (1) time to check whether a given vertex is convex
if the lowest vertex of the polygon is provided.
• It takes O (n) time to check whether a given convex vertex is
an ear.
• Altogether, it takes O (1) + O (n) = O (n) time to check
whether a given vertex is an ear.
• An ear is found at the end of the vertex array in the worst
case.
• Therefore, it takes O (n) * n = O (n2) time to find an ear in
the worst case.
• The pruning of an ear takes O (n) time and this squeezes to O
(1) when the ear is near at the end of the vertex array.
36
Time Complexity…
• Anyway, it takes O (n2) + O (1) = O (n2) time to prune an ear
from a polygon with n vertices.
• There are (n - 3) number of diagonals in the given polygon.
• An ear should be pruned in order to get a diagonal.
• Each step of pruning takes O (n2), O [(n - 1)2]…, O (42) time
complexities.
• Initially, finding the lowest vertex of the polygon takes O (n)
time.
• Therefore, the time complexity of the proposed algorithm is
O (n) + O (n2) + O [(n - 1)2] + O (42) = O (n3).
37
Space Complexity
• It takes n memory cells to hold x-coordinates and n memory
cells to hold y-coordinates.
• Altogether, it takes 2n memory cells to hold the input.
• The additional memory for computations is O (1).
• Therefore, the space complexity of the proposed algorithm is
O (n) + O (1) = O (n).
38
Accuracy
• The proposed algorithm uses integer arithmetic only for
computations.
• Thus, the precision error is avoided.
• The set of output coordinates is a subset of the set of input
coordinates.
39
Comparison
• The basic triangulation algorithm is the only algorithm that
uses integer arithmetic only.
• The other existing algorithms use floating point arithmetic
which leads to the precision error.
• The basic triangulation algorithm takes O (n4) time and O
(n2) space.
• The proposed algorithm uses integer arithmetic only and it is
better than basic triangulation algorithm both in time and
space.
40
Conclusions
41
Conclusion
• The proposed triangulation algorithm is faster than the basic
triangulation algorithm and also performs exact triangulation.
42
Thank you!
43

More Related Content

What's hot

Pseudo and Quasi Random Number Generation
Pseudo and Quasi Random Number GenerationPseudo and Quasi Random Number Generation
Pseudo and Quasi Random Number GenerationAshwin Rao
 
A new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensorsA new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensorsFrancesco Tudisco
 
On the solvability of a system of forward-backward linear equations with unbo...
On the solvability of a system of forward-backward linear equations with unbo...On the solvability of a system of forward-backward linear equations with unbo...
On the solvability of a system of forward-backward linear equations with unbo...Nikita V. Artamonov
 
Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)asghar123456
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsArvind Devaraj
 
The Mathematics of RSA Encryption
The Mathematics of RSA EncryptionThe Mathematics of RSA Encryption
The Mathematics of RSA EncryptionNathan F. Dunn
 
Molecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based ComputingMolecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based Computingijcsit
 
Differential Geometry
Differential GeometryDifferential Geometry
Differential Geometrylapuyade
 
presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve Mukuldev Khunte
 
INVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussain
INVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussainINVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussain
INVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussainficpsh
 
Inverse Trigonometric Functions
Inverse Trigonometric FunctionsInverse Trigonometric Functions
Inverse Trigonometric FunctionsSadiq Hussain
 
Abstract Algebra in 3 Hours
Abstract Algebra in 3 HoursAbstract Algebra in 3 Hours
Abstract Algebra in 3 HoursAshwin Rao
 

What's hot (20)

Numerical Methods 1
Numerical Methods 1Numerical Methods 1
Numerical Methods 1
 
Ch02 7
Ch02 7Ch02 7
Ch02 7
 
Pseudo and Quasi Random Number Generation
Pseudo and Quasi Random Number GenerationPseudo and Quasi Random Number Generation
Pseudo and Quasi Random Number Generation
 
A new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensorsA new Perron-Frobenius theorem for nonnegative tensors
A new Perron-Frobenius theorem for nonnegative tensors
 
Fourier series
Fourier seriesFourier series
Fourier series
 
On the solvability of a system of forward-backward linear equations with unbo...
On the solvability of a system of forward-backward linear equations with unbo...On the solvability of a system of forward-backward linear equations with unbo...
On the solvability of a system of forward-backward linear equations with unbo...
 
AEM Fourier series
 AEM Fourier series AEM Fourier series
AEM Fourier series
 
Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)Amth250 octave matlab some solutions (1)
Amth250 octave matlab some solutions (1)
 
Algo Final
Algo FinalAlgo Final
Algo Final
 
Derivatie class 12
Derivatie class 12Derivatie class 12
Derivatie class 12
 
Signal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier TransformsSignal Processing Introduction using Fourier Transforms
Signal Processing Introduction using Fourier Transforms
 
The Mathematics of RSA Encryption
The Mathematics of RSA EncryptionThe Mathematics of RSA Encryption
The Mathematics of RSA Encryption
 
Molecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based ComputingMolecular Solutions For The Set-Partition Problem On Dna-Based Computing
Molecular Solutions For The Set-Partition Problem On Dna-Based Computing
 
26 Computational Geometry
26 Computational Geometry26 Computational Geometry
26 Computational Geometry
 
Differential Geometry
Differential GeometryDifferential Geometry
Differential Geometry
 
presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve presentation on Euler and Modified Euler method ,and Fitting of curve
presentation on Euler and Modified Euler method ,and Fitting of curve
 
Fourier series
Fourier series Fourier series
Fourier series
 
INVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussain
INVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussainINVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussain
INVERSE TRIGONOMETRIC FUNCTIONS by Sadiq hussain
 
Inverse Trigonometric Functions
Inverse Trigonometric FunctionsInverse Trigonometric Functions
Inverse Trigonometric Functions
 
Abstract Algebra in 3 Hours
Abstract Algebra in 3 HoursAbstract Algebra in 3 Hours
Abstract Algebra in 3 Hours
 

Similar to Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with Lowest Memory Consumption

An Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonAn Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonKasun Ranga Wijeweera
 
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Kasun Ranga Wijeweera
 
An Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonAn Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonKasun Ranga Wijeweera
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic ProgrammingSahil Kumar
 
Recurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptxRecurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptxgbikorno
 
Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)Ha Phuong
 
ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentaryirrrrr
 
Fft presentation
Fft presentationFft presentation
Fft presentationilker Şin
 
Analysis and Enhancement of Algorithms in Computational Geometry
Analysis and Enhancement of Algorithms in Computational GeometryAnalysis and Enhancement of Algorithms in Computational Geometry
Analysis and Enhancement of Algorithms in Computational GeometryKasun Ranga Wijeweera
 
Chap7 2 Ecc Intro
Chap7 2 Ecc IntroChap7 2 Ecc Intro
Chap7 2 Ecc IntroEdora Aziz
 
10-Sequences and summation.pptx
10-Sequences and summation.pptx10-Sequences and summation.pptx
10-Sequences and summation.pptxjaffarbikat
 
High-dimensional polytopes defined by oracles: algorithms, computations and a...
High-dimensional polytopes defined by oracles: algorithms, computations and a...High-dimensional polytopes defined by oracles: algorithms, computations and a...
High-dimensional polytopes defined by oracles: algorithms, computations and a...Vissarion Fisikopoulos
 
Phase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle SystemsPhase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle SystemsStefan Eng
 
Can we estimate a constant?
Can we estimate a constant?Can we estimate a constant?
Can we estimate a constant?Christian Robert
 

Similar to Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with Lowest Memory Consumption (20)

An Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a PolygonAn Algorithm to Find the Visible Region of a Polygon
An Algorithm to Find the Visible Region of a Polygon
 
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
Convex Partitioning of a Polygon into Smaller Number of Pieces with Lowest Me...
 
An Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a PolygonAn Algorithm to Find the Largest Circle inside a Polygon
An Algorithm to Find the Largest Circle inside a Polygon
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Graph
GraphGraph
Graph
 
Graph
GraphGraph
Graph
 
Recurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptxRecurrent Problem in Discrete Mathmatics.pptx
Recurrent Problem in Discrete Mathmatics.pptx
 
Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)Tutorial of topological_data_analysis_part_1(basic)
Tutorial of topological_data_analysis_part_1(basic)
 
ICPC 2015, Tsukuba : Unofficial Commentary
ICPC 2015, Tsukuba: Unofficial CommentaryICPC 2015, Tsukuba: Unofficial Commentary
ICPC 2015, Tsukuba : Unofficial Commentary
 
Fft presentation
Fft presentationFft presentation
Fft presentation
 
Analysis and Enhancement of Algorithms in Computational Geometry
Analysis and Enhancement of Algorithms in Computational GeometryAnalysis and Enhancement of Algorithms in Computational Geometry
Analysis and Enhancement of Algorithms in Computational Geometry
 
Chap7 2 Ecc Intro
Chap7 2 Ecc IntroChap7 2 Ecc Intro
Chap7 2 Ecc Intro
 
10-Sequences and summation.pptx
10-Sequences and summation.pptx10-Sequences and summation.pptx
10-Sequences and summation.pptx
 
UNIT I_5.pdf
UNIT I_5.pdfUNIT I_5.pdf
UNIT I_5.pdf
 
Dsp class 2
Dsp class 2Dsp class 2
Dsp class 2
 
High-dimensional polytopes defined by oracles: algorithms, computations and a...
High-dimensional polytopes defined by oracles: algorithms, computations and a...High-dimensional polytopes defined by oracles: algorithms, computations and a...
High-dimensional polytopes defined by oracles: algorithms, computations and a...
 
Lec9
Lec9Lec9
Lec9
 
Phase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle SystemsPhase-Type Distributions for Finite Interacting Particle Systems
Phase-Type Distributions for Finite Interacting Particle Systems
 
Ecte401 notes week3
Ecte401 notes week3Ecte401 notes week3
Ecte401 notes week3
 
Can we estimate a constant?
Can we estimate a constant?Can we estimate a constant?
Can we estimate a constant?
 

More from Kasun Ranga Wijeweera

Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonKasun Ranga Wijeweera
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingKasun Ranga Wijeweera
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingKasun Ranga Wijeweera
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Kasun Ranga Wijeweera
 

More from Kasun Ranga Wijeweera (20)

Decorator Design Pattern in C#
Decorator Design Pattern in C#Decorator Design Pattern in C#
Decorator Design Pattern in C#
 
Singleton Design Pattern in C#
Singleton Design Pattern in C#Singleton Design Pattern in C#
Singleton Design Pattern in C#
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Algorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a PolygonAlgorithms for Convex Partitioning of a Polygon
Algorithms for Convex Partitioning of a Polygon
 
Geometric Transformations II
Geometric Transformations IIGeometric Transformations II
Geometric Transformations II
 
Geometric Transformations I
Geometric Transformations IGeometric Transformations I
Geometric Transformations I
 
Introduction to Polygons
Introduction to PolygonsIntroduction to Polygons
Introduction to Polygons
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Loops in Visual Basic: Exercises
Loops in Visual Basic: ExercisesLoops in Visual Basic: Exercises
Loops in Visual Basic: Exercises
 
Conditional Logic: Exercises
Conditional Logic: ExercisesConditional Logic: Exercises
Conditional Logic: Exercises
 
Getting Started with Visual Basic Programming
Getting Started with Visual Basic ProgrammingGetting Started with Visual Basic Programming
Getting Started with Visual Basic Programming
 
CheckBoxes and RadioButtons
CheckBoxes and RadioButtonsCheckBoxes and RadioButtons
CheckBoxes and RadioButtons
 
Variables in Visual Basic Programming
Variables in Visual Basic ProgrammingVariables in Visual Basic Programming
Variables in Visual Basic Programming
 
Loops in Visual Basic Programming
Loops in Visual Basic ProgrammingLoops in Visual Basic Programming
Loops in Visual Basic Programming
 
Conditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic ProgrammingConditional Logic in Visual Basic Programming
Conditional Logic in Visual Basic Programming
 
Assignment for Variables
Assignment for VariablesAssignment for Variables
Assignment for Variables
 
Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]Assignment for Factory Method Design Pattern in C# [ANSWERS]
Assignment for Factory Method Design Pattern in C# [ANSWERS]
 
Assignment for Events
Assignment for EventsAssignment for Events
Assignment for Events
 
Mastering Arrays Assignment
Mastering Arrays AssignmentMastering Arrays Assignment
Mastering Arrays Assignment
 

Recently uploaded

Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCEPRINCE C P
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physicsvishikhakeshava1
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PPRINCE C P
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 

Recently uploaded (20)

Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Work, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE PhysicsWork, Energy and Power for class 10 ICSE Physics
Work, Energy and Power for class 10 ICSE Physics
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Artificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C PArtificial Intelligence In Microbiology by Dr. Prince C P
Artificial Intelligence In Microbiology by Dr. Prince C P
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 

Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with Lowest Memory Consumption

  • 1. Accurate, Simple and Efficient Triangulation of a Polygon by Ear Removal with Lowest Memory Consumption Kasun Ranga Wijeweera 1
  • 3. What is a Polygon? • Let v0, v1, v2…, vn-1 be n points in the plane. • Let e0 = v0v1, e1 = v1v2…, ei = vivi+1…, en-1 = vn-1v0 be n segments connecting the points. • These segments bound a polygon if and only if 1. The intersection of each pair of segments adjacent in the cyclic ordering is the single point shared between them: ei ∩ ei+1 = vi+1, for all i = 0…, n – 1. 2. Nonadjacent segments do not intersect: ei ∩ ej = Ф, for all j ≠ i + 1. 3. None of three consecutive vertices are collinear. Note that all index arithmetic are modulo n. 3
  • 6. Triangulation of a Polygon • Definition: The decomposition of a polygon into a set of non overlapping triangles. • Example: 6
  • 7. Research Problem • The basic triangulation algorithm can triangulate a polygon in O (n4) time and O (n2) space with 100% accuracy. • Even though more efficient algorithms are available in literature, they are not 100% accurate due to the use of floating point arithmetic. • A simple and 100% accurate triangulation algorithm is proposed with O (n3) time and O (n) space. 7
  • 9. A Diagonal of a Polygon • If the intersection of line segment AB with ∂P is exactly the set {A, B} and the line segment AB is nowhere exterior to the polygon P then the line segment is called a diagonal of the polygon. 9
  • 10. Basic Triangulation Algorithm • Triangulation Theorem: Every polygon P of n vertices may be partitioned into triangles by the addition of (zero or more) diagonals. • The method suggested by triangulation theorem is an O (n4) algorithm. • There are nC2 = O (n2) diagonal candidates. • Testing each diagonal candidate for diagonalhood costs O (n). • Repeating this O (n3) computation for each of the n – 3 diagonals yields O (n4). 10
  • 11. Triangulation Algorithms • Naïve approach: O (n4) • Lennes (1911): O (n2) • Garey et al. (1978): O (n log n) • Hertel & Mehlhorn (1983): O (n log r), r reflex • Chazelle & Incerpi (1984): O (n log s), s sinuosity • Tarjan & Van Wyk (1988): O (n log log n) • Clarkson et al. (1989): O (n log* n), randomized • Toussaint (1990): O (n + nt0), t0 int. triangs. • Kirkpatrick et al. (1990): O (n log* n), bnded. ints. • Chazelle (1991): O (n) • Seidel (1991): O (n log* n), randomized • Amato et al. (2001): O (n), randomized 11
  • 13. Related Research Paper K. R. Wijeweera, S. R. Kodituwakku (2016), Accurate, Simple, and Efficient Triangulation of a Polygon by Ear Removal with Lowest Memory Consumption, Ceylon Journal of Science, Volume 45 (Issue 3), pp. 65-76. 13
  • 14. An Ear of a Polygon • Suppose P, Q, and R be three consecutive vertices of a polygon. • If PR is a diagonal then PQR is called an ear of the polygon. 14
  • 15. Representation of the Polygon • The variable points stores the number of vertices of the polygon. • The coordinates of the vertices of the polygon are stored using two arrays x and y. • Then (x[i], y[i]) denotes the ith vertex of the polygon where i = 0, 1…, (points - 1). 15
  • 16. Two Known Theorems • Theorem 1: Every polygon of n ≥ 4 vertices has at least two non-overlapping ears. • Theorem 2: Every triangulation of a polygon P of n vertices uses n – 3 diagonals and consists of n – 2 triangles. 16 Vertices = 5 Diagonals = 5 – 3 = 2 Triangles = 5 – 2 = 3
  • 17. The Order of Vertices of a Triangle • The vertices of the triangle: P1 (x1, y1), P2 (x2, y2), P3 (x3, y3). • Let t = x1 * (y2 – y3) + x2 * (y3 – y1) + x3 * (y1 – y2). • t = 0 ↔ (P1, P2, P3) are collinear. • t > 0 ↔ (P1, P2, P3) are in anticlockwise order. • t < 0 ↔ (P1, P2, P3) are in clockwise order. 17 t > 0 t < 0
  • 18. Identifying the Convex Vertices of the Polygon • None of three consecutive vertices of the initial polygon are collinear by the definition of a polygon. • Therefore, each convex vertex is strictly convex. • That means, interior angle formed by each convex vertex is less than π. • Lemma: The lowest vertex of a polygon is strictly convex. 18
  • 19. Identifying the Convex Vertices of the Polygon… • There may be several lowest vertices. • The function lv returns the index of one of those lowest vertices. 19
  • 20. Identifying the Convex Vertices of the Polygon… • Let’s consider the polygon given below as an example. • The function lv returns 0. 20
  • 21. Identifying the Convex Vertices of the Polygon… • The function ts returns the sign of value t when index of middle vertex of three consecutive vertices is provided. • The function isConvex returns 1 if the passed index corresponds to a convex vertex. • If ts (v) * ts (lv ()) > 0 then the vertex v and lowest vertex have the same sign. • If they have the same sign then vertex v is convex. 21
  • 22. Identifying an Ear of the Polygon • An ear should always be with a convex vertex. • The triangles formed by those convex vertices with their two neighboring vertices are considered. • If such a triangle does not contain any of the vertices of the polygon inside it then that triangle should be an ear. 22
  • 23. Identifying an Ear of the Polygon… • The function isEmpty returns 1 if the triangle formed by vertex v does not contain any of the vertices of the polygon. • The function tv returns the sign of value t. This saves lots of computational cost. • The keyword CONTINUE is used to avoid own three vertices of the triangle. IF ((i == v) OR (i == a) OR (i == b)) { CONTINUE; } 23
  • 24. Identifying an Ear of the Polygon… tsv = tv (v, a, b); IF ((tsv * tv (v, a, i) ≥ 0) AND (tsv * tv (a, b, i) ≥ 0) AND (tsv * tv (b, v, i) ≥ 0)) { RETURN 0; } 24
  • 25. Pruning an Ear from the Polygon • Once an ear was found then the algorithm prunes that ear from the original polygon. • This is done by function prune. VOID prune (INTEGER v) { INTEGER i; points = points - 1; FOR (i = v TO (points - 1)) { x[i] = x[i + 1]; y[i] = y[i + 1]; } } 25
  • 26. Pruning an Ear from the Polygon… • The original polygon. 26
  • 27. Pruning an Ear from the Polygon… • After pruning one ear. 27
  • 28. Iterative Process • After pruning two ears. 28
  • 29. Iterative Process… • After pruning three ears. 29
  • 30. Iterative Process… • After pruning four ears. 30
  • 31. Iterative Process… • After pruning five ears. 31
  • 32. Iterative Process… • After pruning six ears. 32
  • 33. Iterative Process… • After pruning seven ears. 33
  • 34. The Triangulated Polygon • Diagonals = 7; Triangles = 8. 34
  • 36. Time Complexity • Let n be the number of vertices in the given polygon. • It takes O (1) time to check whether a given vertex is convex if the lowest vertex of the polygon is provided. • It takes O (n) time to check whether a given convex vertex is an ear. • Altogether, it takes O (1) + O (n) = O (n) time to check whether a given vertex is an ear. • An ear is found at the end of the vertex array in the worst case. • Therefore, it takes O (n) * n = O (n2) time to find an ear in the worst case. • The pruning of an ear takes O (n) time and this squeezes to O (1) when the ear is near at the end of the vertex array. 36
  • 37. Time Complexity… • Anyway, it takes O (n2) + O (1) = O (n2) time to prune an ear from a polygon with n vertices. • There are (n - 3) number of diagonals in the given polygon. • An ear should be pruned in order to get a diagonal. • Each step of pruning takes O (n2), O [(n - 1)2]…, O (42) time complexities. • Initially, finding the lowest vertex of the polygon takes O (n) time. • Therefore, the time complexity of the proposed algorithm is O (n) + O (n2) + O [(n - 1)2] + O (42) = O (n3). 37
  • 38. Space Complexity • It takes n memory cells to hold x-coordinates and n memory cells to hold y-coordinates. • Altogether, it takes 2n memory cells to hold the input. • The additional memory for computations is O (1). • Therefore, the space complexity of the proposed algorithm is O (n) + O (1) = O (n). 38
  • 39. Accuracy • The proposed algorithm uses integer arithmetic only for computations. • Thus, the precision error is avoided. • The set of output coordinates is a subset of the set of input coordinates. 39
  • 40. Comparison • The basic triangulation algorithm is the only algorithm that uses integer arithmetic only. • The other existing algorithms use floating point arithmetic which leads to the precision error. • The basic triangulation algorithm takes O (n4) time and O (n2) space. • The proposed algorithm uses integer arithmetic only and it is better than basic triangulation algorithm both in time and space. 40
  • 42. Conclusion • The proposed triangulation algorithm is faster than the basic triangulation algorithm and also performs exact triangulation. 42