Skip to main content
added 55 characters in body
Source Link
akamayu
  • 1.1k
  • 1
  • 7

APL(Dyalog Unicode), 58 58 56 bytes SBCS

-2 bytes due to unused variable assignment B←.

A dfn that takes the number of edges and outputs a bitmap of the shape.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-B←I∘I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}

It uses complex numbers to encode points on the 2D plane.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-B←I∘I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}
                                             C←¯1*⍵÷⍨+⍨⍳⍵  ⍝ vertces
                     B←I∘I∘.+0J1×I←40÷⍨¯41+⍳81               ⍝ points on the plane
                 C∘.-B                                     ⍝ displacement vectors to the vertices
 (C-C⊖⍨⌈⍵÷2)                                               ⍝ displacement vectors between oppisite vertices
            ∧.>⍥|                                          ⍝ are the points within the reuleaux polygon

Try it on APLgolf!Try it on APLgolf!

APL(Dyalog Unicode), 58 bytes SBCS

A dfn that takes the number of edges and outputs a bitmap of the shape.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-B←I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}

It uses complex numbers to encode points on the 2D plane.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-B←I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}
                                             C←¯1*⍵÷⍨+⍨⍳⍵  ⍝ vertces
                     B←I∘.+0J1×I←40÷⍨¯41+⍳81               ⍝ points on the plane
                 C∘.-B                                     ⍝ displacement vectors to the vertices
 (C-C⊖⍨⌈⍵÷2)                                               ⍝ displacement vectors between oppisite vertices
            ∧.>⍥|                                          ⍝ are the points within the reuleaux polygon

Try it on APLgolf!

APL(Dyalog Unicode), 58 56 bytes SBCS

-2 bytes due to unused variable assignment B←.

A dfn that takes the number of edges and outputs a bitmap of the shape.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}

It uses complex numbers to encode points on the 2D plane.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}
                                           C←¯1*⍵÷⍨+⍨⍳⍵  ⍝ vertces
                     I∘.+0J1×I←40÷⍨¯41+⍳81               ⍝ points on the plane
                 C∘.-                                    ⍝ displacement vectors to the vertices
 (C-C⊖⍨⌈⍵÷2)                                             ⍝ displacement vectors between oppisite vertices
            ∧.>⍥|                                        ⍝ are the points within the reuleaux polygon

Try it on APLgolf!

Source Link
akamayu
  • 1.1k
  • 1
  • 7

APL(Dyalog Unicode), 58 bytes SBCS

A dfn that takes the number of edges and outputs a bitmap of the shape.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-B←I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}

It uses complex numbers to encode points on the 2D plane.

{(C-C⊖⍨⌈⍵÷2)∧.>⍥|C∘.-B←I∘.+0J1×I←40÷⍨¯41+⍳81⊣C←¯1*⍵÷⍨+⍨⍳⍵}
                                             C←¯1*⍵÷⍨+⍨⍳⍵  ⍝ vertces
                     B←I∘.+0J1×I←40÷⍨¯41+⍳81               ⍝ points on the plane
                 C∘.-B                                     ⍝ displacement vectors to the vertices
 (C-C⊖⍨⌈⍵÷2)                                               ⍝ displacement vectors between oppisite vertices
            ∧.>⍥|                                          ⍝ are the points within the reuleaux polygon

Try it on APLgolf!