Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

CONVEX HULL

WITH

Jarvis’s Algorithm

SUBMITED TO SUBMIT BY
DEEPAK SIR Ayush Jain
Somya
What is a Convex Polygon?

Polygon where all interior angles are less than 180 degree

Given any 2 points in the polygon, the Line segment between them

stays inside the polygon

Convex Polygon Concave Polygon


What is a Convex Hull?

Given a set of points in the 2D plane.


the convex hull of the set is the
smallest convex polygon that contains
all the points of it.
What is a Convex Set?
• A set S is said to be convex if for any two points
p,q within S, the convex combination of p and q
lie within S
Applications

Computer Visualization, Ray Tracing,Video Games.

Visual Pattern Matching-Detecting Car License Plates

GPS System

Image Processing
e.g- How Convex Hull Use is GPS SYSTEM
we like to identify in which restaurant a user in eating,even if the r

his reliably work


e.g-Use in Image Processing

-Face Detection -Hand Detection


Before going into the Jarvis’s march algorithm.
Determining what is left and what is right turn in line
segments
Jarvis’s march

Jarvis’s march algorithm uses a process called gift wrapping to find


the convex hull. It is one of the simplest algorithms for computing
convex hull. The working of Jarvis’s march resembles the working of
selection sort. In selection sort, in each pass, we find the smallest
number and add it to the sorted list. Similarly, in Jarvis’s march, we
find the leftmost point and add it to the convex hull vertices in each
pass. The step by step working of Jarvis’s march algorithm is given
below.
Algorithm-

rvis(S)
/ S is the set of points
pointOnHull = leftmost point in S // which is guaranteed to be part of the CH(
=0
epeat
P[i] = pointOnHull
endpoint = S[0] // initial endpoint for a candidate edge on the hull
for j from 1 to |S|
if (endpoint == pointOnHull) or (S[j] is on left of line from P[i] to endpoint)
endpoint = S[j] // found greater left turn, update endpoint
i = i+1
pointOnHull = endpoint
until endpoint == P[0] // wrapped around to first hull point
Jarvis March -Example

p10

p9 p6
p7 p5
p12 p p3
p11 p8 p2
4 p1

p0
Jarvis March -Example

p10

p9 p6
p7 p5
p12 p p3
p11 p8 p2
4 p1

p0

Convex Hull={Po}
Jarvis March -Example

p10

p9 p6
p7 p5
p12 p p3
p11 p8 p2
4 p1

p0

Convex Hull={Po,p1}
Jarvis March -Example

p10

p9 p6
p7 p5
p12 p p3
p11 p8 p2
4 p1

p0

Convex Hull={Po,p1,p3}
Jarvis March -Example

p10

p9 p6
p7 p5
p12 p p3
p11 p8 p2
4 p1

p0

Convex Hull={Po,p1,p3,p10}
Jarvis March -Example

p10

p9 p6
p7 p5
p12 p p3
p11 p8 p2
4 p1

p0

Convex Hull={Po,p1,p3,p10,p12}
Running time

we can find the point q in O(n) time. After repeating


this h times, we will return back to the starting point and
we are done.
Thus, the over all running time is O(n*h).
Worst case efficiency will be n2.
A real-world example that would require computing a
convex hull:

Say we have 3 mixtures containing different


proportions of two liquids A and B. In order to
determine if a new mixture can be formed by
combining the base mixtures, we can compute a
convex hull of the representative points of each of
the base mixtures and check if the point
representing the proportion of the new mixture lies
within the convex hull.
Lets start-

Mixture 1 contains 10% A and 40 % B. Out point 1 is (10,40)


60
50
Mixture 2 contains 40% A and 10 % B. Our point 2 is (40,10) 40
30

Now there is a straight line joining these points of the 20


form y = mx + c 10

where x,y represents the points on the line. 10 20 30 40 50 60 70

Substituting with our coordinates we get


— 40 = 10m + c
— 10 = 40m + c
solving for m and c we get m = -1 and c = 50.

So our line is of the form y = -x + c


Mixture 3 should contain 20% A and 30 % B. To determine Mixture 3 can be formed
using

Mixture 1 and 2 is to determine whether point (20,30) lies on the line segment formed above

n Line y = -x + c , we get

0 (True) therefore, mixture 3 can be formed by the combination of mixtu

You might also like