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

Re^2: circular area in a coordinates grid (AoA)

by bliako (Monsignor)
on Mar 19, 2019 at 23:34 UTC ( [id://1231464]=note: print w/replies, xml ) Need Help??


in reply to Re: circular area in a coordinates grid (AoA)
in thread circular area in a coordinates grid (AoA)

Cool! But that eval poked my eye.

The following can potentially save on some sqrt's too:

my $delta_x = $radius ** 2 - ($center_r - $row) ** 2; if( $delta_x >= 0 ){ $delta_x = int sqrt $delta_x; ...

bw, bliako

Replies are listed 'Best First'.
Re^3: circular area in a coordinates grid (AoA)
by LanX (Saint) on Mar 20, 2019 at 00:20 UTC
    you can also get rid of both squares

    x² = r²-y²

    now increment y2=y+1

    x2² = r²-(y+1)²

    x2² = r²-y² - 2y - 1

    x2² = x² - 2y -1

    I'm too tired to get rid of the sqrt too now :)

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

Re^3: circular area in a coordinates grid (AoA)
by tybalt89 (Monsignor) on Mar 19, 2019 at 23:53 UTC

    Just having some fun :)

    Nothing wrong with having a little fun in a "proof-of-concept" example, is there?
    It's not like it's production code :)

      sorry maybe my comment sounded a bit aggresive (but it wasn't meant to be).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2024-04-23 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found