Implementing Jarvis Binary Search in Chan's algorithm

92 Views Asked by At

Both Wikipedia and Chan's paper state that once Graham's scan has been done to the $n//m$ subsets of our original set $P$, since each subhull is ordered from least to most CCW rotation from its lowest point, we can perform Jarvis March using a binary search on each subhill.

From Wikipedia:

.... The convex hull of the set $Q_k$, $C_k$, is known and contains at most $m$ points (listed in a clockwise or counter-clockwise order), which allows to compute $f(p_{i},Q_{k})$ in $O(\log m)$ time by binary search.

From Chan's paper:

Since tangent finding takes logarithmic time for a convex polygon by binary or Fibonacci search [5], [25***] (the dual problem is to intersect a convex polygon with a ray), the time required for a wrapping step is then O ((n/m) log m). [pg 2] also, compute the point $q_i\in P_i$ that maximizes $\angle p_{k-1}p_k q_i$ by performing a binary search on the vertices of conv(Pi) [pg 3]

I don't know how to do this.

I have looked online for a more complete explanation, but most sources skip the actual implementation of binary jarvis march. I have looked at a few implementations, but their code and implementations of Chan's algortithm on GitHub were not easy to read.

*** I have tried looking through "Computational Geometry: An Introduction - F Peparata, M I Shamos", which was [25] in the first quote Chans paper. Unfortunately, I could not find binary Jarvis. I am not experienced in computational geometry either.

I would greatly appreciate a python implementation of what I'm calling binary jarvis, or at least pseudocode explaining how to write it.

1

There are 1 best solutions below

0
HEKTO On

The inner loop of the regular Jarvis march scans all points in the set P to find the next point of the convex hull. This next point is chosen based on the polar angle between the segment [CurrentPoint, NextPoint] and the OX axis - this angle must be minimized.

However, the variant of the Jarvis march, used in the Chan algorithm, deals with a number of already created convex polygons with vertices, stored in the counterclockwise order. So, the inner loop of this variant doesn't need to scan all the points of these polygons - it can use (kind of) binary search to find tangent lines between the current point and each of these polygons, and then choose the line with minimal polar angle.

As for the Python source code, this one looks good to me. It's not simple, however the Chan algorithm is not simple either.

Also, please see this answer for a similar question - sorry to say, there are no code/pseudocode there.