Boolean function for intersection between circular segment and circle

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Boolean function for intersection between circular segment and circle

Post by Ref »

Hi pgimeno!
Sorry for late reply but have suffered a major power outage.
Discovered that the edge case failures in my code was related to " relational operator" failure.
When determining if circle was within radius of sector, the conditional statement occasional fails.

dis = distance of circle circle to center of arc => using sqrt distance calculation
lng = radius of segment
rad = radius of circle
condition: dis < (lng + rad)
test: print( dis, lng, rad, dis<(lng+rad) )
failure prints: "260,250,10,true"
If I round the distance (math.round(dis,3), I don't get the failure.
?
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Boolean function for intersection between circular segment and circle

Post by pgimeno »

Ref wrote: Sun Aug 15, 2021 2:51 pm Hi pgimeno!
Sorry for late reply but have suffered a major power outage.
Discovered that the edge case failures in my code was related to " relational operator" failure.
When determining if circle was within radius of sector, the conditional statement occasional fails.

dis = distance of circle circle to center of arc => using sqrt distance calculation
lng = radius of segment
rad = radius of circle
condition: dis < (lng + rad)
test: print( dis, lng, rad, dis<(lng+rad) )
failure prints: "260,250,10,true"
If I round the distance (math.round(dis,3), I don't get the failure.
?
Uh? Can you give a complete function? Also, math.round is not standard lua, so please include it as well.

But my understanding is that the failures have to do with the angle comparisons, not with the distance comparisons.
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: Boolean function for intersection between circular segment and circle

Post by Gunroar:Cannon() »

pgimeno wrote: Wed Aug 11, 2021 5:49 pm edit: nvm, too off-topic
Oh, no!! I missed this. My OCD :?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 34 guests