W Karas wrote:
> wade wrote:
> > wade wrote:
> > > pramod wrote:
> > > > Karas: Can you please explain your code?
> > >
> > > I'll try.
> >
> > Sorry, I was explaining Karthik's method which seems to be correct, not
> > Karas's code, which seems to be incorrect.
> >
> > Karas's method is to sort the endpoints in order of increasing angle
> > and then run:
> >
> > for (i = 0; i < (2 * v.size()); i++)
> > {
> > if (ep[i].start())
> > tot -= endNotSeen++;
> > else
> > tot += --endNotSeen;
> > }
> >
> >
> > return(tot);
>
> Oops, sorry, should be:
>
> int endNotSeen = 0, tot = 0;
>
> for (i = 0; i < (2 * v.size()); i++)
> {
> if (ep[i].start())
> endNotSeen++;
> else
> {
> endNotSeen--;
> tot += endNotSeen;
> }
> }
>
> return(tot);
Sorry, this is also incorrect.
> > Suppose I have three chords. Their endpoint angles (in degrees) are
> > A {1,3}
> > B {2,5}
> > C {4,6}
> >
> > There are two intersections (AxB and BxC), but with Kara's method, at
> > the bottom of each loop iteration, I see values for {ep[i].theta,
> > ep[i].start, endNotSeen, tot}
> >
> > {1,T,1,0}
> > {2,T,2,-1}
> > {3,F,1,0}
> > {4,T,2,-1}
> > {5,F,1,0}
> > {6,F,0,0}
> >
> > For a final, incorrect, result of zero intersections.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---