Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: circular area in a coordinates grid (AoA)

by LanX (Cardinal)
on Mar 19, 2019 at 22:18 UTC ( #1231458=note: print w/replies, xml ) Need Help??


in reply to circular area in a coordinates grid (AoA)

I understand your problem as a classic fill circle with pixels problem.

In computer graphics in the age before specialized graphic processors they used very fast algorithms giving you the edges of a circle for each line and filled that line between the edges.

Since the second level array in your AoA you just need the indices of left and right border. And an array slice will fill it effectively.

@line[$left..$right] = ('x') X ($right-$left)

You'll also need a max and min against the start of the borders of your array.

I don't think a highly optimized algorithm to calculate the border is necessary, basic sinus and cosinus should be fast enough here.

HTH! :)

Edit

After thinking it through you don't even need sinus. Pythagoras should do already.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1231458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2020-11-25 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?