Convex Hull
Problem
Introduction to
Convex Hull
Defination:The Convex Hull Problem
involves finding the smallest convex
polygon that can enclose a given set of
points in a plane. It’s the tightest
boundary that can be drawn around all
the points, often visualized as
stretching a rubber band around them.
01. Computer Graphics and
Applications
Image Processing
of Convex Hull 02. Robotics and Path
Planning
03. Geographic Information Systems
(GIS)
05. Data Analysis and
Machine Learning
Applications
of Convex Hull 06. Economics and Game
Theory
04. Computational
Geometry
07. Computer vision
DIVIDE AND CONQUER
APPROCH FOR
CONVEX HULL
PROBLEM
1. Divide:
Sort the points based on their
X-coordinates.
Recursively divide the set of points into two
halves (left and right).
2. Conquer:
Compute the convex hull for the left half
and the right half separately using recursion.
3. Merge:
Combine the two convex hulls by finding
the upper and lower tangent lines that
connect the two hulls.
Merge the two halves along these tangents
to form the final convex hull.
4. Time Complexity:
The divide and conquer approach for
convex hulls has a time complexity of O(n
log n), which is more efficient than some
other methods such as the brute force
approach (O(n²))
Algorithms
steps of
Convex Hull
problem
Graham’s Scan Algorithm:
Step 1: Find the point with the lowest y-coordinate (if ties, choose the leftmost point). This point is the starting point (P0
Step 2: Sort the remaining points by the polar angle with respect to P0.
Step 3: Initialize a stack with the first three points.
Step 4: Iterate through the sorted points, checking whether each point makes a left turn or a right turn with respect to the last two
points on the stack.
If it makes a right turn, pop the top of the stack.
If it makes a left turn, push the point onto the stack.
Step 5: Continue until all points are processed. The points in the stack form the convex hull
Jarvis March (Gift Wrapping) Algorithm:
Step 1: Start with the leftmost point, as it will always be part of the convex hull.
Step 2: Select the point that forms the smallest positive angle (or largest negative angle) with the current point.
Step 3: Repeat the process to find the next point that forms the smallest angle with respect to the last two points, wrapping
around the points like "gift wrapping".
Step 4: Continue this until you return to the starting point.
Step 5: The selected points form the convex hull.
Divide and Conquer Algorithm:
Step 1: Sort the points by their x-coordinates.
Step 2: Recursively divide the points into two halves until each subset contains a small number of points (e.g., 2 or
3).
Step 3: Compute the convex hull for each subset of points.
Step 4: Merge the two hulls by identifying the upper and lower tangents between the two convex hulls.
Step 5: Combine the two convex hulls to form the final convex hull
EXAMPLE AND VISUALIZATION
Consider the following set of points:
{(0, 0), (1, 3), (2, 2), (4, 4), (5, 1), (6, 2), (7, 0), (3, -1)}
We want to find the convex hull, which is the smallest convex polygon that can enclose all these points.
# Steps Using Graham’s Scan Algorithm:
1. *Find the Starting Point:*
- The point with the lowest y -coordinate is (0, 0). (If there were ties, we would choose the leftmost one.)
2. *Sort Points by Polar Angle:*
- Sort the remaining points based on the polar angle with respect to (0, 0).
3. *Initialize Stack:*
- Start with the point (0, 0) and the first two points from the sorted list.
4. *Iterate and Maintain Convexity:*
- For each point in the sorted list, check if moving from the last two points in the stack to the current point forms a
left turn or a right turn. Pop from the stack if a right turn is detected and push the current point if a left turn is
detected.
5. *Form the Convex Hull:*
- Continue this process until all points are processed. The points in the stack represent the convex hull.
Visualization
Imagine plotting the points on a Cartesian plane:
1. Plot the points: (0, 0), (1, 3), (2, 2), (4, 4), (5, 1), (6, 2), (7, 0), and (3, -1).
2. Draw lines connecting these points following the convex hull algorithm.
The convex hull will be a polygon that surrounds all the points, and it will look like
this:
*Visual
(0,0) - (5,1) - (7,0) - (4,4) - (1,3) - (2,2) - (6,2) - (3,-1)
Representation:*
(1,3) (4,4)
*---------*
/ \
/ \
(0,0) * *
(7,0)
\ /
\ /
*--------*
(5,1) (3,-1)
*Edges:* Draw lines connecting (0,0) to (5,1), (5,1) to (7,0), (7,0) to (4,4), (4,4) to (1,3), (1,3) to (2,2),
(2,2) to (6,2), and (6,2) to (3, -1), and back to (0,0).
This polygon represents the convex hull of the set of points, encompassing all the given points within its
boundary.
CONCLUSION
Key Takeaways:
1.Definition
: The Convex Hull is the smallest convex polygon enclosing a set of points in a
plane.
2.Significance:
Essential for applications in computer graphics, collision detection, clustering, and geographic information
systems.
3.Algorithms:
• Graham’s Scan: Efficient with O(n log n) time
complexity.
• Jarvis March (Gift Wrapping): Simple but less efficient for large datasets,
O(nh).
• Divide and Conquer: Combines subproblems efficiently with O(n log n)
complexity
4.Applications:
Used in spatial analysis, pattern recognition, and optimization problems.
5.Visualization:
Helps in understanding the geometric properties of the convex hull and its practical importance
SUMMARY:
The Convex Hull Problem is crucial in computational geometry, offering insights into geometric
algorithms and their real-world applications. Efficient algorithms make it feasible to solve for large
datasets, making it a foundational problem with broad applicability.
Visual Aids:
• Include a diagram showing the convex hull surrounding a set of points.
• Use charts or graphs to illustrate the time complexities of different
algorithms.
Thank you !
PRESENTED BY
V.BHANU PRAKASH
SE23UARI127