rrufai / StreamedConvexHull

0 stars 0 forks source link

Details for some calls in Algorithm description #3

Closed yasminmo closed 11 years ago

yasminmo commented 11 years ago

Add details for the following calls in the algorithm: a. polar(p; L:c) b. area(L:pred(p); p; L:succ(p))

rrufai commented 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

yasminmo commented 11 years ago

Hello Raimi, What if (p.x - c.x) is zero while calculating the polar?

Y.

rrufai commented 11 years ago

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

rrufai commented 11 years ago

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 .

yasminmo commented 11 years ago

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 }

rrufai commented 11 years ago

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