Constrained random points on a circle: Difference between revisions

→‎{{header|Go}}: adding sample in gnuplot
(→‎{{header|Go}}: adding sample in gnuplot)
Line 1,218:
* * ** *
*</pre>
=={{header|gnuplot}}==
{{Works with|gnuplot|5.0 (patchlevel 3) and above}}
[[File:RingRandPntsGnu.png|right|thumb|Output RingRandPntsGnu.png]]
 
<lang gnuplot>
## Ring of random points 2/18/17 aev
reset
fn="RingRandPntsGnu";
ttl="Ring of random points"
ofn=fn.".png"; lim=1000;
randgp(top) = floor(rand(0)*top)
set terminal png font arial 12 size 640,640
set output ofn
set title ttl font "Arial:Bold,12"
unset key;
set size square
set parametric
set xrange [-20:20]; set yrange [-20:20];
set style line 1 lt rgb "red"
$rring << EOD
EOD
set print $rring append
do for [i=1:lim] {
x=randgp(30); y=randgp(30);
r=sqrt(x**2+y**2);
if (r>=10&&r<=15) \
{print x," ",y; print -x," ",-y;print x," ",-y; print -x," ",y;}
}
plot [0:2*pi] sin(t)*10,cos(t)*10, sin(t)*15,cos(t)*15 ls 1,\
$rring using 1:2 with points pt 7 ps 0.5 lc "black"
set output
unset print
</lang>
{{Output}}
<pre>
File: RingRandPntsGnu.png
</pre>
 
=={{header|Go}}==
'''Algorithm 1:'''
Anonymous user