<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Pi Day Challenge: Draw Newton's diagram for approximating pi in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863164#M23574</link>
    <description>&lt;P&gt;In the spirit of Pi Day, and motivated by the great holiday posts by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4628"&gt;@tc&lt;/a&gt;,&amp;nbsp;I&amp;nbsp;thought I'd post a challenge for the graphics gurus. While writing &lt;A href="https://blogs.sas.com/content/iml/2023/03/08/newton-pi.html" target="_self"&gt;a Pi Day blog post about how Isaac Newton approximated pi to 16 decimals places&lt;/A&gt;, I needed to create a diagram that shows the geometry that Newton used in the calculation. I was in a hurry, so I used PowerPoint to create the image.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My challenge: &lt;STRONG&gt;Can you create the image by using PROC SGPLOT (or the GTL)?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll give you a hint: &lt;A href="https://blogs.sas.com/content/iml/2020/03/11/polygons-pi-linear-approx.html" target="_self"&gt;Archimedes knew that you could approximate a circle to any accuracy by using a polygon with many sides.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To keep it simple, you do NOT have to use the square-root symbol in your plot; use 'sqrt(3)' instead.&lt;/P&gt;
&lt;P&gt;Here's the figure from my Pi Day post. Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NewtonPi1.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81251i072A184B1B63505A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NewtonPi1.png" alt="NewtonPi1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 11:47:50 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2023-03-09T11:47:50Z</dc:date>
    <item>
      <title>Pi Day Challenge: Draw Newton's diagram for approximating pi</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863164#M23574</link>
      <description>&lt;P&gt;In the spirit of Pi Day, and motivated by the great holiday posts by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4628"&gt;@tc&lt;/a&gt;,&amp;nbsp;I&amp;nbsp;thought I'd post a challenge for the graphics gurus. While writing &lt;A href="https://blogs.sas.com/content/iml/2023/03/08/newton-pi.html" target="_self"&gt;a Pi Day blog post about how Isaac Newton approximated pi to 16 decimals places&lt;/A&gt;, I needed to create a diagram that shows the geometry that Newton used in the calculation. I was in a hurry, so I used PowerPoint to create the image.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My challenge: &lt;STRONG&gt;Can you create the image by using PROC SGPLOT (or the GTL)?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll give you a hint: &lt;A href="https://blogs.sas.com/content/iml/2020/03/11/polygons-pi-linear-approx.html" target="_self"&gt;Archimedes knew that you could approximate a circle to any accuracy by using a polygon with many sides.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To keep it simple, you do NOT have to use the square-root symbol in your plot; use 'sqrt(3)' instead.&lt;/P&gt;
&lt;P&gt;Here's the figure from my Pi Day post. Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NewtonPi1.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81251i072A184B1B63505A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NewtonPi1.png" alt="NewtonPi1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 11:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863164#M23574</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-03-09T11:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Pi Day Challenge: Draw Newton's diagram for approximating pi</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863378#M23578</link>
      <description>&lt;P&gt;Rick,&lt;/P&gt;
&lt;P&gt;Finally, I got it worked . It is really uneasy. Have fun with the following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
id1=1;
do theta=0 to constant('pi') by 0.01;
 x=0.5*cos(theta)+0.5; y=0.5*sin(theta);output;
end;

id2=1;
do theta=0 to (2/3)*constant('pi') by 0.01;
 _x=0.5*cos(theta)+0.5; _y=0.5*sin(theta);output;
end;
_x=0.25;_y=0;output;

x1=0.5;  y1=0.66;output;
x1=1.32; y1=0;output;

x2=0.5; y2=0;datalabel='C';output;
x2=0;   y2=0;datalabel='O';output;
x2=0.25;y2=0;datalabel='A';output;
x3=0.25;y3=sqrt(3)/4;datalabel='B';output;
run;


%sganno

data sganno;
 %SGARROW( X1=0, Y1=0,X2=0,Y2=100,DIRECTION= "OUT",X1SPACE="DATAVALUE",Y2SPACE="WALLPERCENT",
            X2SPACE="DATAVALUE",Y1SPACE="DATAVALUE",LINECOLOR="blue" ,SHAPE="BARBED" )
 %SGARROW( X1=0, Y1=0,X2=100,Y2=0,DIRECTION= "OUT",X1SPACE="DATAVALUE",Y2SPACE="DATAVALUE",
            X2SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",LINECOLOR="blue" ,SHAPE="BARBED" )

%SGTEXT( LABEL="O",ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0, Y1=0, WIDTH=12)
%SGTEXT(LABEL="0", ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0,Y1=-0.05,WIDTH=12)

%SGTEXT( LABEL="A",ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.25, Y1=0, WIDTH=12)
%SGTEXT(LABEL="1/4", ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.25,Y1=-0.05,WIDTH=12)

%SGTEXT( LABEL="C  ",ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.5, Y1=0, WIDTH=12)
%SGTEXT(LABEL="1/2", ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.5,Y1=-0.05,WIDTH=12)

%SGTEXT(LABEL="M", ANCHOR="BOTTOM" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.125,Y1=0.1,WIDTH=12,FILLCOLOR="white")
%SGTEXT(LABEL="r = 1/2", ANCHOR="BOTTOMLEFT" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.4,Y1=0.2,WIDTH=12)
%SGTEXT( LABEL="x",ANCHOR="TOP" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=95, Y1=0, WIDTH=12,FILLTRANSPARENCY=1)
%SGTEXT( LABEL="y",ANCHOR="RIGHT" , X1SPACE="DATAVALUE",Y1SPACE="WALLPERCENT",TEXTSIZE= 12,X1=0, Y1=90, WIDTH=12,FILLTRANSPARENCY=1)
%SGTEXT( LABEL="3/4  ",ANCHOR="RIGHT" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=0, Y1=0.433, WIDTH=12,FILLTRANSPARENCY=1)

%SGTEXT( LABEL="(*ESC*){unicode '221A'x}",ANCHOR="RIGHT" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=-3, Y1=0.433, WIDTH=12,FILLTRANSPARENCY=1)
%SGTEXT( LABEL="(*ESC*){unicode '2013'x}",ANCHOR="RIGHT" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=-1.7, Y1=0.448, WIDTH=12,FILLTRANSPARENCY=1)
run;


proc sgplot data=have noborder aspect=0.5 sganno=sganno noautolegend pad=(left=40);
polygon id=id1 x=x y=y/fillpattern nofill fillpatternattrs=(color=brown);
polygon id=id2 x=_x y=_y/fill fillattrs=(color=white);

series x=x y=y/smoothconnect lineattrs=(color=blue thickness=2);
scatter x=x1 y=y1/markerattrs=(size=0);

scatter x=x3 y=y3/markerattrs=(symbol=circlefilled) 
        datalabel=datalabel datalabelpos=topleft datalabelattrs=(size=12);
scatter x=x2 y=y2/markerattrs=(symbol=circlefilled) ;
vector x=x3 y=y3/xorigin=0.5 yorigin=0 noarrowheads lineattrs=(color=blue thickness=2);
dropline x=x3 y=y3/dropto=x lineattrs=(pattern=solid color=blue thickness=2) ;
dropline x=x3 y=y3/dropto=y lineattrs=(pattern=shortdash color=blue thickness=2) ;

yaxis offsetmin=0.01 offsetmax=0   label='y' display=none min=-0.006 ;
xaxis offsetmin=0.01 offsetmax=0  label='x' display=none;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1678434332925.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81308iB312906628016E37/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1678434332925.png" alt="Ksharp_0-1678434332925.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 07:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863378#M23578</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-03-10T07:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pi Day Challenge: Draw Newton's diagram for approximating pi</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863387#M23579</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*I forgot the vertical symbol*/
data have;
id1=1;
do theta=0 to constant('pi') by 0.01;
 x=0.5*cos(theta)+0.5; y=0.5*sin(theta);output;
end;

id2=1;
do theta=0 to (2/3)*constant('pi') by 0.01;
 _x=0.5*cos(theta)+0.5; _y=0.5*sin(theta);output;
end;
_x=0.25;_y=0;output;

x1=0.5;  y1=0.66;output;
x1=1.32; y1=0;output;

x2=0.5; y2=0;datalabel='C';output;
x2=0;   y2=0;datalabel='O';output;
x2=0.25;y2=0;datalabel='A';output;
x3=0.25;y3=sqrt(3)/4;datalabel='B';output;

id3=1;x4=0.3;y4=0.05;output;
id3=1;x4=0.3;y4=0;output;
id3=2;x4=0.3;y4=0.05;output;
id3=2;x4=0.25;y4=0.05;output;

run;


%sganno

data sganno;
 %SGARROW( X1=0, Y1=0,X2=0,Y2=100,DIRECTION= "OUT",X1SPACE="DATAVALUE",Y2SPACE="WALLPERCENT",
            X2SPACE="DATAVALUE",Y1SPACE="DATAVALUE",LINECOLOR="blue" ,SHAPE="BARBED" )
 %SGARROW( X1=0, Y1=0,X2=100,Y2=0,DIRECTION= "OUT",X1SPACE="DATAVALUE",Y2SPACE="DATAVALUE",
            X2SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",LINECOLOR="blue" ,SHAPE="BARBED" )

%SGTEXT( LABEL="O",ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0, Y1=0, WIDTH=12)
%SGTEXT(LABEL="0", ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0,Y1=-0.05,WIDTH=12)

%SGTEXT( LABEL="A",ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.25, Y1=0, WIDTH=12)
%SGTEXT(LABEL="1/4", ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.25,Y1=-0.05,WIDTH=12)

%SGTEXT( LABEL="C  ",ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.5, Y1=0, WIDTH=12)
%SGTEXT(LABEL="1/2", ANCHOR="TOP" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.5,Y1=-0.05,WIDTH=12)

%SGTEXT(LABEL="M", ANCHOR="BOTTOM" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.125,Y1=0.1,WIDTH=12,FILLCOLOR="white")
%SGTEXT(LABEL="r = 1/2", ANCHOR="BOTTOMLEFT" , DRAWSPACE= "DATAVALUE" ,TEXTSIZE= 12,X1=0.4,Y1=0.2,WIDTH=12)
%SGTEXT( LABEL="x",ANCHOR="TOP" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=95, Y1=0, WIDTH=12,FILLTRANSPARENCY=1)
%SGTEXT( LABEL="y",ANCHOR="RIGHT" , X1SPACE="DATAVALUE",Y1SPACE="WALLPERCENT",TEXTSIZE= 12,X1=0, Y1=90, WIDTH=12,FILLTRANSPARENCY=1)
%SGTEXT( LABEL="3/4  ",ANCHOR="RIGHT" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=0, Y1=0.433, WIDTH=12,FILLTRANSPARENCY=1)

%SGTEXT( LABEL="(*ESC*){unicode '221A'x}",ANCHOR="RIGHT" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=-3, Y1=0.433, WIDTH=12,FILLTRANSPARENCY=1)
%SGTEXT( LABEL="(*ESC*){unicode '2013'x}",ANCHOR="RIGHT" , X1SPACE="WALLPERCENT",Y1SPACE="DATAVALUE",TEXTSIZE= 12,X1=-1.7, Y1=0.448, WIDTH=12,FILLTRANSPARENCY=1)

run;


proc sgplot data=have noborder aspect=0.5 sganno=sganno noautolegend pad=(left=40);
polygon id=id1 x=x y=y/fillpattern nofill fillpatternattrs=(color=brown);
polygon id=id2 x=_x y=_y/fill fillattrs=(color=white);

series x=x y=y/smoothconnect lineattrs=(color=blue thickness=2);
scatter x=x1 y=y1/markerattrs=(size=0);

scatter x=x3 y=y3/markerattrs=(symbol=circlefilled) 
        datalabel=datalabel datalabelpos=topleft datalabelattrs=(size=12);
scatter x=x2 y=y2/markerattrs=(symbol=circlefilled) ;
vector x=x3 y=y3/xorigin=0.5 yorigin=0 noarrowheads lineattrs=(color=blue thickness=2);
dropline x=x3 y=y3/dropto=x lineattrs=(pattern=solid color=blue thickness=2) ;
dropline x=x3 y=y3/dropto=y lineattrs=(pattern=shortdash color=blue thickness=2) ;

series x=x4 y=y4/group=id3 lineattrs=(pattern=solid color=blue thickness=2) ;

yaxis offsetmin=0.01 offsetmax=0   label='y' display=none min=-0.006 ;
xaxis offsetmin=0.01 offsetmax=0  label='x' display=none;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1678438897635.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81309iBC108A22BD6B751D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1678438897635.png" alt="Ksharp_0-1678438897635.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 09:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/863387#M23579</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-03-10T09:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Pi Day Challenge: Draw Newton's diagram for approximating pi</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/864177#M23589</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; posted a very nice program. Anyone want to solve it without using the annotation facility?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 23:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Pi-Day-Challenge-Draw-Newton-s-diagram-for-approximating-pi/m-p/864177#M23589</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-03-14T23:20:10Z</dc:date>
    </item>
  </channel>
</rss>

