Closed yasminmo closed 11 years ago
Hi Yasmin,
Here are the formulas.
polar(Point p, Point c) = arctan((p.y - c.y)/(p.x - c.x))
area( Point a, Point b, Point c) =0.5 * abs(a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y))
Let me know, if anything isn't clear.
Many thanks
Hello Raimi, What if (p.x - c.x) is zero while calculating the polar?
Y.
Hi Yasmin, Great question!
if((p.x - c.x) == 0) { polar = Math.signum(p.y - c.y) < 0? -1 * Math.PI/2 : Math.PI/2 }
Many thanks
Hi Yasmin, Great question!
if((p.x - c.x) == 0) { polar = Math.signum(p.y - c.y) < 0? -1 * Math.PI/2 : Math.PI/2 }
Many thanks
On Sat, Apr 20, 2013 at 8:30 PM, yasminmo notifications@github.com wrote:
Hello Raimi, What if (p.x - c.x) is zero while calculating the polar?
Y.
— Reply to this email directly or view it on GitHubhttps://github.com/rrufai/StreamedConvexHull/issues/3#issuecomment-16713810 .
So this is the right formula?
if((p.x - c.x) == 0) { polar = Math.signum(p.y - c.y) < 0? -1 * Math.PI/2 : Math.PI/2 }
Yes, except that you might want to do:
if((p.x - c.x) < EPSILON) rather than if((p.x - c.x) == 0)
for some small EPSILON (say, 10 ^ (-16)) but that is just a technicality ...
Regards,
Raimi
Add details for the following calls in the algorithm: a. polar(p; L:c) b. area(L:pred(p); p; L:succ(p))