Constrained random points on a circle: Difference between revisions

m
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(4 intermediate revisions by 3 users not shown)
Line 1,050:
end;
end.</syntaxhighlight>
 
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=bY0xDsIwFEP3nOKN0Igqv6hMzWGqtohIJYhPBMntUShsbLafZb8uYV2YYmJAnDNAxqNjnENMHIUDcqpx+R8rnsddE7tMQ8ZSaCj7ysIZcQweZYwzWqX0lcDn03rka6+350LvsNSdbpN1qvv1g07rsvVb05o3 Run it]
 
<syntaxhighlight>
while cnt < 100
x = randint 31 - 16
y = randint 31 - 16
r = sqrt (x * x + y * y)
if 10 <= r and r <= 15
cnt += 1
move 50 + x * 2 50 + y * 2
circle 1
.
.
</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 3,638 ⟶ 3,654:
 
[[File:CalmoSoftDrawCircle.jpg]]
 
=={{header|RPL}}==
{{works with|HP|48G}}
« ERASE -15 15 DUP2 XRNG YRNG <span style="color:grey">@ set graphics boundaries</span>
DEG -19 SF 0 <span style="color:grey">@ set degrees mode, polar vector mode, count = 0</span>
'''DO''' RAND 5 * 10 + RAND 360 * →V2 <span style="color:grey">@ z = rand(10..15).exp(i.rand(360))</span>
C→R IP SWAP IP R→C <span style="color:grey">@ make z a complex with integer coordinates</span>
'''IF''' DUP ABS DUP 10 ≥ SWAP 15 ≤ AND <span style="color:grey">@ if 10 ≤ | z | ≤ 15</span>
'''THEN''' PIXON 1 + <span style="color:grey">@ then set pixel and increment count</span>
'''ELSE''' DROP '''END'''
'''UNTIL''' DUP 100 ≥ '''END'''
DROP { } PVIEW
-19 CF
» '<span style="color:blue">TASK</span>' STO
[[File:Constrained.png|alt=Screenshot of a HP-48G emulator, displaying constrained random points on a circle|HP-48G emulator screenshot]]
 
The circle is actually an ellipse because RPL display screens are not squared.
 
=={{header|Ruby}}==
Line 3,926 ⟶ 3,959:
{{trans|Perl}}
Generates an EPS file.
<syntaxhighlight lang="ruby">var points = [];
while (points.len < 100) {
var (x, y) = 2.of{31 30.rand.intirand - 15 }...;
var r2 = (x**2 + y**2);
if ((r2 >= 100) && (r2 <= 225)) {
points.append([x, y]);
}
}
 
print <<'HEAD';
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox 0 0 400 400
Line 3,947 ⟶ 3,980:
HEAD
 
points.each { |pt| say "#{pt.join(' ')} pt" };
print '%%EOF';</syntaxhighlight>
 
=={{header|Standard ML}}==
2,041

edits