Draw the Ionising Radiation Hazard Symbol

35

6

Draw the ionising-radiation-hazard-symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government.

Details

  • As output, writing to a file (raster and vector formats are permitted) or displaying on the screen are both allowed.

  • You can draw just the border or the filled shape.

  • If you use raster images, you should take a parameter (or two) as input that lets you adjust the resolution of the output (e.g. width/height).

  • The background must at least have the size of the bounding box of the symbol but may be larger.

  • Outputting the unicode symbol ☢ is not sufficient.

  • The exact ratios of the used distances are given in following diagram (which was originally from here):

Related: Draw the ☣ (Biohazard Symbol)

flawr

Posted 2019-11-23T17:45:45.840

Reputation: 40 560

Can I take an input n such that the image has width 2*n+1? – Luis Mendo – 2019-11-23T18:50:27.397

@LuisMendo Sure! – flawr – 2019-11-23T19:42:04.197

1Is it ok to return an integer matrix of 0s and 1s as the representation of the bitmap image? – Nick Kennedy – 2019-11-23T21:36:34.380

@NickKennedy That doesn't seem to be exaclty covered by the default I/O methods for image related challenges. So it's flawr's call

– Luis Mendo – 2019-11-23T23:42:39.790

@LuisMendo I can make my program output a Netpbm file but it would cost 14 bytes to do so and feels unnecessary since it’s just prepending `P1 L L ‘ to the beginning where L is the length. But I agree, it’s flawr’s call. – Nick Kennedy – 2019-11-23T23:44:18.467

Can we write a function that takes x and y and returns the color at (x, y)? (one can pretend that's an array but with parentheses) – my pronoun is monicareinstate – 2019-11-24T01:25:38.427

2@NickKennedy I'd say a matrix just as a data type is not enough, but if it is printed nicely with two different characters as the "colours" (and no separators in between) it should be ok. – flawr – 2019-11-24T08:37:20.307

@mypronounismonicareinstate That is an interesting idea! Unfortunately I think that would change the answers in most languages so I say no fo rnow, but we should definitely reconsider this for [tag:graphical-output] challenges! As far as I understand this is more or less how pixelshaders work, right? – flawr – 2019-11-24T08:38:35.603

@flawr I'm pretty sure that's how they work (I'm not sure I understand the difference between pixel and fragment shaders well, but you might be referring to fragment shaders instead; but the difference is absolutely insignificant). – my pronoun is monicareinstate – 2019-11-24T08:48:20.000

1

@mypronounismonicareinstate I added the twos suggestions in the "defaults for IO" on meta, please vote. (1) (2)

– flawr – 2019-11-24T09:43:03.113

Answers

34

BBC BASIC, 200 bytes

f=500
g=1/SQR(3)
CIRCLE FILLf,f,f
GCOL15
MOVE-100,f
MOVEf,f
PLOT85,f*(1-g),0
MOVE1100,f
MOVEf,f
PLOT85,f*(1+g),0
MOVEf*(1-g),2*f
MOVEf,f
PLOT85,f*(1+g),2*f
CIRCLE FILLf,f,150
GCOL0
CIRCLE FILLf,f,100

Somehow outgolfing Python, this works by drawing a large black circle, filling in the white triangular sections, drawing a central white circle and finally drawing the central black circle.

Beta Decay

Posted 2019-11-23T17:45:45.840

Reputation: 21 478

21I guess you couldn't resist answering this challenge! – Neil – 2019-11-24T00:48:25.987

11-1 I'm sure you are using insider knowledge! – flawr – 2019-11-25T10:22:26.983

17

MATL, 46 44 41 bytes

:t_0vSt!Yy1MZ;3*YP/koyG.3*>*yG<*wG5/<=3YG

Given an input n, the image has width 2*n+1 in pixels.

Try it at MATL Online!

Explanation

:       % Implicit input n. Range [1 ... n]
t_      % Duplicate, negate. Gives [-1 ... -n]
0       % Push 0
v       % Concatenate stack as a column vector: [1; ...; n; -1; ...; -n; 0]
S       % Sort. Gives [-n; -n+1; ... n]
t!      % Duplicate, transpose. Gives the row vector [-n -n+1 ... n]
Yy      % Hypotenuse, with implicit expansion. Gives a matrix containing radius
        % for all points in a grid from -n to -n
1M      % Push the two inputs of the last function, again
Z;      % atan2, with implicit expansion. Gives a matrix containing angle between
        % -pi and pi, where 0 is real positive semiaxis
3*YP/k  % Multiply by 3, divide by pi, round down. Gives an integer for each sextant
o       % Parity. This assigns 0 and 1 alternately to points in different sextants.
        % See this partial result as IMAGE 1 below.
y       % Duplicate from below: pushes the matrix of radii again
G.3*>   % Greater than 0.3*n?, element-wise. Gives 0 or 1 for each entry. This
        % realizes the "1.5R" circle from the specification. See IMAGE 2
*       % Multiply, element-wise. See IMAGE 3
y       % Duplicate from below: pushes the matrix of radii again
G<      % Less than n?, element-wise. Gives 0 or 1 for each entry. This realizes
        % the "5R" circle from the specification. See IMAGE 4
*       % Multiply, element-wise. See IMAGE 5
w       % Swap: pushes the original matrix of radii to the top
G5/<    % Mess than 0.2*n? This realizes the "R" circle in the spec. See IMAGE 6
=       % Equal?, element-wise. This combines the two matrices so far to produce
        % the final result, with 0 for foreground pixels and 1 for background pixels.
        % See IMAGE 7
3YG     % Show image. 0 is displayed as black, 1 as white

Intermediate results. 0 is shown as black, 1 as white:

  • Image 1:

enter image description here

  • Image 2:

enter image description here

  • Image 3:

enter image description here

  • Image 4:

enter image description here

  • Image 5:

enter image description here

  • Image 6:

enter image description here

  • Image 7 (final result):

enter image description here

Luis Mendo

Posted 2019-11-23T17:45:45.840

Reputation: 87 464

15

SVG(HTML5), 175 bytes

<svg viewBox=-24,-24,48,48><circle r=4 /><path id=b d=M3,-5.2A6,6,0,0,1,6,0H20A20,20,0,0,0,10,-17.32z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240)

Originally based on @Arnauld's answer, but removes unnecessary characters, scales the numbers by 80% to make them golfier, and draws the curved section's lines in a different order so that I can use an H instead of an L.

Neil

Posted 2019-11-23T17:45:45.840

Reputation: 95 035

I only get one of the three outer parts, in data:text/html (Chrome 78.0.3904.106), oddly enough – Redwolf Programs – 2019-11-23T21:49:11.467

@RedwolfPrograms Hmm... I get one only if I forget to escape the # as %23, although I only get all three if I append a >... – Neil – 2019-11-24T00:45:13.973

I see you and I raise you ;). 128 bytes - see here

– G0BLiN – 2019-11-24T16:46:21.170

@G0BLiN Very clever - similar to the BBC BASIC solution I guess? – Neil – 2019-11-24T21:50:21.097

@Neil - I admit I didn't read the details of that answer until you've pointed it out, but yes - that's the exact approach Beta Decay used there - I just felt that there's aught to be a better way than writing use href=#b transform=rotate(120) twice... – G0BLiN – 2019-11-26T12:51:15.120

15

Jelly, 42 bytes

÷ÆṬ÷ØPḂ×3ḞḂ
æịA©>5,1.5aç^/o®Ị¤
×5ŒR÷µçþAZY

Try it online!

A full program that takes an integer n that determines the radius of the central circle and implicitly outputs to STDOUT a \$10n+1\$ square with the desired image encoded as 1 for black and 0 for white.

Per @flawr, this is a permitted output format. Note also that this is effectively a PBM file without the header. Adding P1 L L to the start (where L is replaced by \$10n+1\$) would make it a valid PBM file. Ta

Explanation

Helper link 2

Dyadic link taking y coordinate as left and x as right argument; returns whether the angle is within the filled outer area

÷           | Divide (y by x)
 ÆṬ         | Arc-tangent
   ֯P      | Divide by pi
      Ḃ     | Mod 2
       ×3   | Times 3
         Ḟ  | Floor
          Ḃ | Mod 2

Helper link 1

Dyadic link taking y coordinate as left and x as right argument

æị                 | Convert to complex
  A                | Absolute (i.e. distance from origin)
   ©               | Copy to register
    >5,1.5         | Greater than 5,1.5 (vectorises, so will give two booleans)
          a        | Logical and with:
           ç       | - Result of helper link 2 applied to the input of this link
            ^/     | Reduce using exclusive or
              o  ¤ | Or following as a nilad:
               ®   | Value in register
                Ị  | Absolute of this <= 1

Main link

×5         | Times 5
  ŒR       | Range from -this to +this
    ÷      | Divide by input
     µ     | Start a new monadic chain
      çþ   | Outer table using helper link 1 and:
        A  | - Absolute of the range as the right argument
         Z | Transpose rows and columns

Sample image for n=5

sample

Nick Kennedy

Posted 2019-11-23T17:45:45.840

Reputation: 11 829

Again, those are characters not bytes. – DomQ – 2019-11-26T11:20:31.430

8@DomQ what do you mean? If you’re discussing the scoring for code golf, the established standard on this site is to use language specific encodings where they exist. Jelly has its own 256 character code page linked to through the Jelly header on my answer. I note a couple of my answers including this one were downvoted recently; if that was you and it was for this reason, I’d respectfully ask you to reconsider since this is the way this SE site has agreed to function. – Nick Kennedy – 2019-11-26T11:27:16.737

ah well, I didn't know that. (But I didn't downvote either.) – DomQ – 2019-11-26T18:42:25.590

@DomQ As per my previous comment, there are a number of languages used regularly here that have single byte encodings with their own codepage. These include 05AB1E, Jelly, APL, Charcoal, Stax. The accepted standard for scoring them is to score them based on bytes <b>in their own codepage</b>. It is possible to have a 42 byte file, pass it to the Jelly interpreter and get the output above. Note these code pages are part of the language. In general, inventing a codepage for a specific answer (i.e. with knowledge of the question) is not so acceptable. There are also posts on meta about this. – Nick Kennedy – 2019-11-26T18:46:06.293

15

SVG(HTML5), 128 126 124 120 bytes

(Thanks Wheat Wizard for saving 2 bytes by using .2 rather than 0.2)
(Drawing triangles from right to left saves 2 bytes)
(Thanks Grimmy for saving 2 bytes by using a modified path)
(And reduced another 2 bytes by using a different starting point on the path)

 <svg viewbox=-2,-2,4,4>
  <circle r=1 />
  <circle r=.3 fill=#FFF />
  <path d=m2,3.4V0h-4v3.4l4,-6.8h-4 fill=#FFF />
  <circle r=.2

<svg viewbox=-2,-2,4,4><circle r=1 /><circle r=.3 fill=#FFF /><path d=m2,3.4V0h-4v3.4l4,-6.8h-4 fill=#FFF /><circle r=.2

Rather than basing the SVG on wikipedia's vector image - which is drawn in a reasonable way, this solution draws:

  1. A black large circle <circle r=1 />
  2. A smaller white circle <circle r=.3 fill=#FFF />
  3. Three white triangles as a single continuous path <path d=m2,3.4V0h-4v3.4l4,-6.8h-4 fill=#FFF />
  4. And a small black circle <circle r=.2

Taking advantage of modern browsers forgiving interpretation which ignores unclosed tags (saved the final 9 bytes of /></svg> )

This is the result:

SVG output

And this is the same code with the path in yellow to demonstrate what's going on: enter image description here

G0BLiN

Posted 2019-11-23T17:45:45.840

Reputation: 270

1Welcome to the site! This is not rendering the small black circle on my browser (firefox). Even if I add the /><svg> – Post Rock Garf Hunter – 2019-11-24T17:07:06.180

1I just tested on chrome as well and it doesn't seem to work there. For the record it is fine if it only works in a specific browser (you should indicate which in your question so it can be tested). I just want to make sure you haven't made an accident. – Post Rock Garf Hunter – 2019-11-24T17:09:05.240

@WheatWizard - Added a snippet for this code - I can see the small black circle in Firefox and Chrome in it - can you please let me know if it works now for you? – G0BLiN – 2019-11-24T20:45:52.127

1Thanks. That snippet does work for me. And since I can now test it I can confirm that both 0.2 and 0.3 can have the 0 removed to save two bytes. Could you also include the exact code without the extra whitespace? It is fine to add the whitespace for readability but since whitespace does matter it is always best to include the code you are scoring. – Post Rock Garf Hunter – 2019-11-24T21:50:27.373

@WheatWizard - Thanks, applied your suggestion. Also, I'm leaving the snippet code with no whitespaces - since that's what's running. Do you think I should also remove the line breaks from the basic code block (I think that in that case I can just remove it entirely as it'll look exactly like the snippet code)? – G0BLiN – 2019-11-24T22:48:59.497

1l-1,1.7 can be L1,1.7 for -1 byte. – Grimmy – 2019-11-25T12:50:04.670

@Grimmy - thanks, missed the l vs. L notion in your comment, so misunderstood it as suggesting to draw the triangle path from right to left - that saves 2 bytes so I've incorporated that to the answer. I'm pretty sure I can still utilize some mixture of absolute and relative coordinates to golf this even more - but don't have the time to do the math right now... – G0BLiN – 2019-11-26T12:46:25.917

1d=m2,0h-4v3.4l4,-6.8h-4l4,6.8 saves another two bytes. – Grimmy – 2019-11-26T13:40:17.333

@Grimmy - right you are, added to answer. – G0BLiN – 2019-11-26T16:32:24.267

Additionally, starting from the lower point of the triangle by replacing d=m2,0 with d=m2,3.4V0 (+4 bytes) allows to omit the final l4,6.8 (-6 bytes) for a total -2 bytes. – G0BLiN – 2019-11-26T16:32:57.010

11

JavaScript (ES7),  118 113 98  93 bytes

Saved 15 bytes thanks to @tsh!

Takes a parameter \$w\$ as input and draws an ASCII art of width \$2w-1\$ and height \$2w\$, using 0 and 1 for the 'pixels'.

f=(x,w=y=x)=>y+w?(--x+w?(r=x*x+y*y,4*x*x>r^y<0?1019:3)>>r**.5/w*10&1:(x=w,y--,`
`))+f(x,w):''

Try it online!

How?

We compute the squared distance from the center:

$$r=x^2+y^2$$

We use \$\sqrt{r}\$ to quantize the distance from the center into 10 bins of width \$w\$:

$$\left\lfloor\frac{10\sqrt{r}}{w}\right\rfloor$$

We use \$r\$, \$x\$ and \$y\$ to determine in which kind of sector we are:

$$(4x^2>r)\text{ xor }(y<0)$$

See this graph!

We turn the above result into a drawing bit-mask, as summarized in the following schema:

schema

Hence the value of the pixel at \$(x,y)\$:

(
  r = x * x + y * y,
  4 * x * x > r ^ y < 0 ?
    1019
  :
    3
)
>> r ** 0.5 / w * 10
& 1

Arnauld

Posted 2019-11-23T17:45:45.840

Reputation: 111 334

2

Maybe you can use the fact that $ \sin30^{\circ} = \frac 1 2 $. it could be 105 bytes

– tsh – 2019-11-25T11:24:12.043

3

And removing Math, it is 98 bytes

– tsh – 2019-11-25T11:31:19.637

1@tsh This is brilliant! – Arnauld – 2019-11-25T11:39:35.237

8

HTML / SVG,  201  189 bytes

A revamped version of this file from Wikimedia Commons.

<svg viewBox=-30,-30,60,60><circle r=5 /><path id=b d=M7.5,0A7.5,7.5,0,0,0,3.7,-6.5L12.5,-21.6A25,25,0,0,1,25,0z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240) />

Arnauld

Posted 2019-11-23T17:45:45.840

Reputation: 111 334

175 bytes: <svg viewBox=-24,-24,48,48><circle r=4 /><path id=b d=M3,-5.2A6,6,0,0,1,6,0H20A20,20,0,0,0,10,-17.32z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240) – Neil – 2019-11-23T18:40:10.810

2@Neil You've basically done all the job here, so feel free to post it as your own answer. – Arnauld – 2019-11-23T18:41:42.193

7

C (gcc) (MinGW), 245 244 242 236 223 221 bytes

-6 bytes thanks to ceilingcat.

Added -lm on TiO so that it works there. MinGW does not require it.

Outputs a 3-shade PGM file to STDOUT. Takes width (height is the same) of image as a command line argument.

main(q,v,r,c,m)char**v;{*v=calloc(q+1,q=atoi(v[1]));float R=q/10.1,d;for(r=m=q/2;r--+m;)for(c=m;c--+m;m[*v+(r+m)*q+c]=d<R*5&&d<=R|d>=1.5*R&asin(r/d)+1.5707>(r>0?5:1)*0.5235?:2)d=hypot(c,r);printf("P5 %d %d 2 %s",q,q,*v);}

Try it online!

gastropner

Posted 2019-11-23T17:45:45.840

Reputation: 3 264

Perhaps I'm not understanding what I'm looking at, but when I try the 'Try it online!' I just a huge blob of "hollow square" characters. ??? – Bob Jarvis - Reinstate Monica – 2019-11-24T16:20:49.237

@BobJarvis-ReinstateMonica Yeah, it outputs a PGM file using ASCII 1 and 2, which look a bit wonky. Redirect to a file on a local system or copy the TiO output into a file to see the result. – gastropner – 2019-11-24T18:36:09.940

6

Haskell (code.world dialect), 108 86 bytes

drawingOf(c(2)&colored(c(3),white)&0%1&2%3&4%5)
c=solidCircle
a%b=sector(a*60,b*60,10)

Run on code.world!

Joseph Sible-Reinstate Monica

Posted 2019-11-23T17:45:45.840

Reputation: 556

5

TikZ, 170 bytes

\documentclass[tikz]{standalone}\begin{document}\tikz{\fill circle(10);\foreach\a in{0,120,240}{\fill[white]circle(3)--(\a-60:13)--(\a:13);}\fill circle(2)}\end{document}

flawr

Posted 2019-11-23T17:45:45.840

Reputation: 40 560

it can be reduced to 164 bytes with TikZ – Black Mild – 2020-01-30T01:25:49.200

5

Desmos/Cartesian Plane, 103 97 86 84 bytes

(23 arithmetic and comparison operators)

(abs(mod(arctan(x,-y)/\pi*6,4)-2)-1)*max(0,182-abs(x^2+y^2-218))+max(0,16-x^2-y^2)>0

enter image description here

https://www.desmos.com/calculator/hadw7gayfn

enter image description here

Will Chen

Posted 2019-11-23T17:45:45.840

Reputation: 81

2Bah, stupid calculator can't graph it as a polar equation... can you at least save some bytes by using degrees instead of radians? (You can also change the grid to polar, which looks nicer IMHO.) – Neil – 2019-11-27T01:01:26.790

5

Google Sheets, 277 bytes

=ARRAYFORMULA((POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)<A1*A1)+(POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)>9/4*A1*A1)*(POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)<25*A1*A1)*IFERROR((MOD(3*ATAN2(COLUMN(A1:CV99)-5*A1,ROW(A1:CV99)-5*A1)/PI(),2)<1),0

Creates a grid of 1s and 0s which can be coloured using a conditional format. It takes input in cell A1 as the value of R.

Here's a link.

enter image description here

Matthew Jensen

Posted 2019-11-23T17:45:45.840

Reputation: 713

4

python 3.8, 220


from PIL import Image as I
from math import*
d=300
h=d//2
r0=d/10
g=range(-h,h)
i=I.frombytes('L',(d,d),bytes([255,0][1.5<(r:=(x*x+y*y)**.5)/r0<5 and(atan2(x,y)/pi+7/6)*1.5%1.>.5 or r<r0]for y in g for x in g))
i.show()

The idea behind is very simple: we count (x,y) from the center of image and r=(x*x+y*y)**.5 is the distance between point and the center.
The point is black if either r<r0 where r0 is 1/5 distance from center to a side
or if 5*r0<r<1.5*r0 (see the diagram in the question) and the angle from center to the point (computed with math.atan2) is in selected ranges. 1.5 and 7/6 there were obtained almost empirically, but could be reasoned too.
The other (most) part is a wrap-in.

Alexey Burdin

Posted 2019-11-23T17:45:45.840

Reputation: 844

I don't fully understand this code, but is there any reason for h=d//2 instead of h=150? Or r0=d/10 instead of say k=30.? – 79037662 – 2019-11-23T22:55:48.067

1No reason except If you use raster images, you should take a parameter (or two) as input that lets you adjust the resolution of the output (e.g. width/height). so it should be d=int(input()) – Alexey Burdin – 2019-11-24T04:45:57.393

Is there a point to the leading newline? Or to assigning to i instead of calling.show() on the result? – Jo King – 2019-11-24T05:57:58.457

You seem to be aware that the resolution should be inputted, but your code has it hardcoded instead. Also, r0 can just be a different single letter variable – Jo King – 2019-11-24T06:06:29.150

OK you can count +9 bytes for input and -3 bytes for r0, but I especially like score of 220 in the context of danger, it's the power voltage (220V) in xUSSR usual consumer voltage) – Alexey Burdin – 2019-11-24T12:41:55.797

So you're changing the rules because you didn't like your score? – Anders Kaseorg – 2019-11-25T20:05:53.997

4

Red, 237 218 bytes

Red[needs: 'View]
g: func[n][a: compose[arc(s: n / 2.0 * 50x50)(s)60 60 closed
rotate 120(s)]view compose/deep[base(s * 2)draw[(f: 'fill-pen)black(a)(a)(a)
pen gray line-width(0.1 * s/1)(f)black circle(s)(s/1 / 4.0)]]]

enter image description here

Takes a parameter n - the width/height in multiples of 50.

Galen Ivanov

Posted 2019-11-23T17:45:45.840

Reputation: 13 815

4

Logo, 96 bytes

circle 16
rt 90
repeat 3[arc 80 60
arc 24 60
pu
repeat 2[fw 24
pd
fw 56
pu
backward 80
rt 60]pd]

Try it online! Draws just the border.

Neil

Posted 2019-11-23T17:45:45.840

Reputation: 95 035

4

Mathematica, 93 88 85 76 74 70 bytes

RegionPlot[1.5<#<5&&Sin[3#2]>0||#<1&@@AbsArg[x+I y],{x,-5,5},{y,-5,5}]

-4 bytes thanks to Roman.

It is not clear from the description whether it is required to get rid of the outline and make it black on white, but I think the submission looks best and is shortest like this.

radiation symbol

Mario Carneiro

Posted 2019-11-23T17:45:45.840

Reputation: 258

170 bytes: RegionPlot[3/2<#<5&&Sin[3#2]>0||#<1&@@AbsArg[x+I*y],{x,-5,5},{y,-5,5}] – Roman – 2019-11-27T21:22:35.337

3

Ruby, 91 100 bytes

->s{(w=-(s/=2)..s).map{|x|w.map{|r|a=x*x+r*=r;' O'[a<(b=s*s)/25||a>b/11&&a<b&&x*(r*4-a)<0?1:0]}*''}}

Try it online!

Accepting 1 parameter (size of the image).

Example output for s=40:

          O                   O          
         OO                   OO         
       OOOOO                 OOOOO       
      OOOOOO                 OOOOOO      
     OOOOOOOO               OOOOOOOO     
     OOOOOOOOO             OOOOOOOOO     
    OOOOOOOOOO             OOOOOOOOOO    
   OOOOOOOOOOOO           OOOOOOOOOOOO   
   OOOOOOOOOOOO           OOOOOOOOOOOO   
  OOOOOOOOOOOOOO         OOOOOOOOOOOOOO  
  OOOOOOOOOOOOOO         OOOOOOOOOOOOOO  
 OOOOOOOOOOOOOOOO       OOOOOOOOOOOOOOOO 
 OOOOOOOOOOOOOOOO       OOOOOOOOOOOOOOOO 
 OOOOOOOOOOOOOOO         OOOOOOOOOOOOOOO 
 OOOOOOOOOOOOOO   OOOOO   OOOOOOOOOOOOOO 
 OOOOOOOOOOOOOO  OOOOOOO  OOOOOOOOOOOOOO 
 OOOOOOOOOOOOOO  OOOOOOO  OOOOOOOOOOOOOO 
                 OOOOOOO                 
                 OOOOOOO                 
                 OOOOOOO                 
                  OOOOO                  


                 OOO OOO                 
                OOOOOOOOO                
                OOOOOOOOO                
               OOOOOOOOOOO               
               OOOOOOOOOOO               
              OOOOOOOOOOOOO              
              OOOOOOOOOOOOO              
             OOOOOOOOOOOOOOO             
            OOOOOOOOOOOOOOOOO            
            OOOOOOOOOOOOOOOOO            
           OOOOOOOOOOOOOOOOOOO           
           OOOOOOOOOOOOOOOOOOO           
            OOOOOOOOOOOOOOOOO            
              OOOOOOOOOOOOO

G B

Posted 2019-11-23T17:45:45.840

Reputation: 11 099

3

Python 3.8, 129 124 122 120 119

def f(N):[print((abs(a:=(i%N+i//N*1j)*2/N-1-1j)<.2)+((a**3).imag<0<.3<abs(a)<1),end=(-i%N==1)*"\n")for i in range(N*N)]

Output (N=20):

00000000000000000000
00000000000000000000
00000100000000010000
00011100000000011100
00011110000000111100
00111111000001111110
01111111000001111111
01111111100011111111
01111111000001111111
01111111011101111111
00000000011100000000
00000000011100000000
00000000000000000000
00000000010100000000
00000000111110000000
00000000111110000000
00000001111111000000
00000011111111100000
00000011111111100000
00000011111111100000

The idea is to represent each point in the plane by a complex number \$x\$. Let the radius of the innermost circle be \$2\$. Then \$x\$ is inside the inner circle if \$|x|<2\$.

The outer parts are a bit more involved. To lie in one of the outer parts, we have to have \$3=1.5\cdot 2< |x| < 5\cdot 2 = 10\$ so that the distance is neither too small nor too large. We also have an angle restriction: the polar angle of \$x\$ has to lie between \$60^\circ\$ and \$120^\circ\$, when taken mod \$120^\circ\$. But if we instead look at \$x^3\$, the angle is multiplied by three, so that the polar angle of \$x^3\$ has to lie between \$180^\circ\$ and \$360^\circ\$ (mod \$360^\circ\$). This is just equivalent to \$\Im(x^3)<0\$.

To put it all together, we have to have \$|x|<2\$ or both of \$3<|x|<10\$ and \$\Im(x^3)<0\$ for \$x\$ to be inside the image. As both conditions are mutually exclusive, their truth values can just be added together.

ManfP

Posted 2019-11-23T17:45:45.840

Reputation: 481

@Brian Minton You're right - I used len("""...""") in Python to calculate the length, which of course counted the "\n" as one char... Sorry about that – ManfP – 2019-11-25T23:28:10.233

3

Mathematica (Wolfram Language) 76 71 Bytes

This solution draws the radiation symbol using only the Disk[] primitive, which allows for arcs.

By default a Graphics object in Mathematica has a White background and objects are Black unless otherwise specified. So we first draw three black disk sectors, then a small white disk and finally a smaller inner black disk. Unlike @Mario Carneiro's solution (which is a nice use of RegionPlot), this comes without axes and without the artifacts produced by the inner workings of RegionPlot.

Saved a byte by letting R=2

Graphics@{(d={0,0}~Disk~##&)[10,{#,#+1}Pi/3]&/@{0,2,4},{White,d@3},d@2}

enter image description here

Kelly Lowder

Posted 2019-11-23T17:45:45.840

Reputation: 3 225

2

PostScript, 183 175 bytes

Code (compressed version):

20 20 scale 9 6 translate<</f{closepath fill}/c{0 360 arc f}/l{10 0 lineto -60 rotate}>>begin 0 0 5 c 1 setgray 3{0 0 moveto l l f} repeat 0 0 1.5 c 0 setgray 0 0 1 c showpage

Code (uncompressed version):

20 20 scale           % over-all scale
9 6 translate         % over-all shift

% define some short-named procedures for later use
<<
  /f { closepath fill }
  /c { 0 360 arc f }  % filled circle (x, y, radius are taken from stack)
  /l { 10 0 lineto
       -60 rotate }   % long line + rotate by 60°
>> begin

0 0 5 c               % big black circle
1 setgray             % set white color
3 {
  0 0 moveto l l f    % white triangle + rotate by 120°
} repeat
0 0 1.5 c             % white circle
0 setgray             % set black color
0 0 1 c               % small black circle
showpage

Result (as animation to see how it is drawn):

result

Thomas Fritsch

Posted 2019-11-23T17:45:45.840

Reputation: 361

1

GLSL / Shadertoy, 181 bytes

void mainImage(out vec4 o,vec2 c)
{
    vec2 p=(c-iResolution.xy/2.)/iResolution.y;
    float k=length(p),h=acos(-1.)/3.;
    o=step(0.,min(k-.1,max(k-.5,.15-k)*step(mod(atan(p.y,p.x),h+h),h)))-o;
}

Copy and paste this code into the editor then press the play button to run the shader.

The shader uses the signed distance of the shapes to be able to use the union and intersection operations to generate the symbol.

Gábor Fekete

Posted 2019-11-23T17:45:45.840

Reputation: 2 809

1

OpenSCAD, 153 bytes

module a(){polygon([[0,0],[5,0],[5,10]]);}module b(){a();rotate(120)a();rotate(240)a();}circle();intersection(){difference(){circle(5);circle(1.5);}b();}

A low-poly radiation symbol

Uncompressed:

module triangle()
{
    polygon(points=[[0,0],[5,0],[5,10]]);
}

module triangles() {
    triangle();
    rotate(120) triangle();
    rotate(240) triangle();
}

module radiation()
{
    circle($fn = 100);
    intersection() {
        difference() {
            circle(5, $fn = 100);
            circle(1.5, $fn = 100);
        }
        triangles();
    }
}

radiation();

A high-poly radiation symbol

Notice the extra $fn = 100 in the circles, which are used to make them higher-resolution polygon. We could add $fs=.1; at the beginning of the file, which would also improve the resolution.

Larry B.

Posted 2019-11-23T17:45:45.840

Reputation: 111

1

Runic Enchantments, 216 bytes

D::i</~1-:0)?;{:}ak$2?X2    8?1]$#'~~\1?7 c?1$ '~~\?3  L
R:0)?/1-:̹{2,::}}-S{-2pS2p+'qA:{5,:}≮?/:}3,2*S:}S≯?/5,)?/]:̹{2,:}-S{-:̹'-A}'-A0)3*?P2?Z0]{{S:0)a*?:0(4*?~~10,'|A'aA{0)?S-:0≮4*?P2*+3*2P*%P)4*?'#2?' $]

Try it online!

Dear god. Why.
So much went wrong.
It makes me cry.

Several major impediments that ended up making this both (a) a nearly unreadable mess and (b) frustratingly difficult.

The first problem was the fact that Runic doesn't have atan2(x,y), so I had to heckin' work that out myself. And oh yeah, make sure its reasonably golfed, it had to be dropped into an existing program with no alterations, so in-line conditional logic was preferable.

The second problem was that I had a weird issue where I'd multiply the tangent value by 3, modulo to 2pi and get...nonsense. What even is that? Why is it not using angular values? Turned out I had a stray extra value at the bottom of the stack that was throwing the math off. Whoops.

THEN
AND THEN
The program would just suddenly die after the first four bytes of the outer wedges. Oh my, what fun we had. Lets simplify, shall we? Lets just isolate the inputs at that point and... oh. It works fine.

I.

Uh.

Hmm.

When in doubt, check the source code. Can you spot the difference?

Yep. Integer values are totes allowed to divide by zero (and return infinity) and doubles aren't. Oh and that's not even true in the original Unity C# code (which I use as a graphical debugger) as it was an intentional design decision to terminate on div-by-zero.

Wot. Also, conversion to float instead of double for no reason. Just sittin' there.

(╯°Д°)╯︵┻━┻

Explanation

I need a drink first.
dook dook
That's better.

D::i<                     Set up the stack, we need a current position (X,Y) and total size. Init all to read value, counting down is easier than counting up.
                          The D here, and the R below it, constitute the main loop entry
R:0)?\1-                  Compare current X against zero, else decrement
     \~1-:0)?;{:}ak$      if zero, decrement Y. If Y is zero, terminate, else return to the D on the first line (there's a lot of skip-over-logic)
:̹ {2,::}}-S{-             dupe the entire stack, then translate origin by 1/2 width
2pS2p+'qA                 square root (x*x+y*y)
:{5,:}≮?\:}3,2*S:}S≯?\    compare that against 1/20th the width and 1.5/20th the width (R and 1.5R)
  ]$#'~~L       $ '~~L    Print # or <space> for the inner circle (and return to D) skip-bypasses omitted
5,)?/                     Compare against 1/10th the width (5R), print a space and return to D 

]:̹ {2,:}-S{-:̹ '-A}'-A0)3*?P2?Z0]{{S:0)a*?:0(4*?~~10,'|A'aA{0)?S-    Dupe the entire stack and compute atan2(x,y)

:0≮4*?P2*+                       Convert negative values to values greater than pi up to 2 pi
          3*2P*%P)4*?'#2?' $]    Multiply by 3, modulo 2pi, compare against pi. Less: print # else print space. Return to R.

Be wary of improperly stacking unicode combining characters. The little ̹ makes the command apply to the stack-of-stacks and ̸ is boolean-not; eg. is "not less than (aka greater-equals)." Looks like it costs bytes, but because of the upper line, there's a byte savings in that line being shorter, which pays for the +1 byte cost for an extended character in the lower line (typically assuming that the lower line could be ?!/ instead of ?/).

Draco18s no longer trusts SE

Posted 2019-11-23T17:45:45.840

Reputation: 3 053

1

TikZ, 164 bytes

\documentclass[tikz]{standalone}\begin{document}\tikz{\foreach\i in{0,120,240}\fill[rotate=\i](60:3)arc(60:0:3)--(0:10)arc(0:60:10);\fill circle(2)}\end{document}

enter image description here

Black Mild

Posted 2019-11-23T17:45:45.840

Reputation: 111

0

TI-BASIC (TI-84+), 1042 bytes

"000000000000000000000000000000000000000000000000000000000000000300000000000000780000006000001FC000000F800003FC000001FC00007FE000001FE0000FFE000003FF0001FFF000003FF8003FFF000007FFC003FFF80000FFFC007FFFC0000FFFE00FFFFC0001FFFF00FFFFE0001FFFF01FFFFE0003FFFF81FFFFF0007FFFF83FFFFF8007FFFFC3FFFFF800FFFFFC3FFFFFC00FFFFFC7FFFFFC01FFFFFE7FFFFFC01FFFFFE7FFFFF801FFFFFE7FFFFF0F0FFFFFEFFFFFE3FC7FFFFFFFFFFE7FE7FFFFFFFFFFC7FE3FFFFFFFFFFCFFF3FFFFFFFFFFCFFF3FFFFF000000FFF3FFFFF000000FFF0000000000007FE0000000000007FE0000000000003FC0000000000000F0000000000000000000000000000604000000000000FFE000000000001FFE000000000001FFF000000000003FFF800000000007FFF800000000007FFFC0000000000FFFFC0000000000FFFFE0000000001FFFFF0000000003FFFFF0000000003FFFFF8000000007FFFFF8000000007FFFFFC00000000FFFFFFC00000001FFFFFFE00000001FFFFFFF00000003FFFFFFF00000001FFFFFFF80000000FFFFFFF000000003FFFFFC0000000007FFFE000000000007FE000000→Str1
AxesOff
15→N
4→dim(∟A
For(I,1,60N
sub(Str1,I,1
inString("0123456789ABCDEF",Ans)-1→D
For(B,4,1,-1
D≥2(B-1→∟A(B
If ∟A(B
D-2^(B-1→D
End
For(E,1,4
If ∟A(5-E
Pxl-On(iPart(I/N),E+4remainder(I,N
End
End

Oh man, this one was rough. The TI series of calculators do have shading functionality between functions, but that just don't cut it.
Furthermore, I was limited to 60x60 pixels, since drawing on the 62nd row or lower would result in ERR: ARGUMENT error being thrown and 60 fits the radii ratios mentioned in the challenge perfectly: $$ R = 12 \\ 1.5R = 18 \\ 5R = 60$$

So, I opted to convert a string of hexadecimal characters to pixels.

The pixels drawn to the screen will look like this:

Ionized Radiation Hazard symbol

The very long string you see on the first line of the program looks like this when formatted:

000000000000000
000000000000000
000000000000000
000000000000000
000300000000000
000780000006000
001FC000000F800
003FC000001FC00
007FE000001FE00
00FFE000003FF00
01FFF000003FF80
03FFF000007FFC0
03FFF80000FFFC0
07FFFC0000FFFE0
0FFFFC0001FFFF0
0FFFFE0001FFFF0
1FFFFE0003FFFF8
1FFFFF0007FFFF8
3FFFFF8007FFFFC
3FFFFF800FFFFFC
3FFFFFC00FFFFFC
7FFFFFC01FFFFFE
7FFFFFC01FFFFFE
7FFFFF801FFFFFE
7FFFFF0F0FFFFFE
FFFFFE3FC7FFFFF
FFFFFE7FE7FFFFF
FFFFFC7FE3FFFFF
FFFFFCFFF3FFFFF
FFFFFCFFF3FFFFF
000000FFF3FFFFF
000000FFF000000
0000007FE000000
0000007FE000000
0000003FC000000
0000000F0000000
000000000000000
000000604000000
000000FFE000000
000001FFE000000
000001FFF000000
000003FFF800000
000007FFF800000
000007FFFC00000
00000FFFFC00000
00000FFFFE00000
00001FFFFF00000
00003FFFFF00000
00003FFFFF80000
00007FFFFF80000
00007FFFFFC0000
0000FFFFFFC0000
0001FFFFFFE0000
0001FFFFFFF0000
0003FFFFFFF0000
0001FFFFFFF8000
0000FFFFFFF0000
00003FFFFFC0000
000007FFFE00000
0000007FE000000

Each hexadecimal digit encodes to a series of 4 pixels drawn to the screen. For each bit set in the digit, a pixel will be drawn.

Explanation:

"000 ... 000→Str1                       ;set the digit string to convert
AxesOff                                 ;get rid of the axes on the graph since
                                        ;  it'll be in the way
15→N                                    ;set N to 15 in order to save a few bytes
4→dim(∟A                                ;set the length of the list A to 4 elements
For(I,1,60N                             ;loop 900 times.  There are 60 lines to draw
                                        ;  and 15 digits per line to convert
sub(Str1,I,1                            ;get the current hexadecimal digit
inString("0123456789ABCDEF",Ans)-1→D    ;convert it to base 10, store the result in D
For(B,4,1,-1                            ;convert number to its binary representation
D≥2(B-1→∟A(B
If ∟A(B
D-2^(B-1→D
End
For(E,1,4                               ;loop over each bit in said representation
If ∟A(5-E                               ;and only draw the pixel if this bit is set
                                        ; (bit order is reversed)
Pxl-On(iPart(I/N),E+4remainder(I,N      ;pixel row (Y) is I/N, pixel column (X) is
                                        ; 4*(I%N)+E
End
End

Note: TI-BASIC is a tokenized language. Character count does not equal byte count.

Tau

Posted 2019-11-23T17:45:45.840

Reputation: 1 935