A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,25 @@
|
|||
link graphics
|
||||
|
||||
procedure main(A) # points, inside r, outside r in pixels - default to task values
|
||||
|
||||
if \A[1] == "help" then stop("Usage: plot #points inside-radius outside-radius")
|
||||
points := \A[1] | 100
|
||||
outside := \A[2] | 15
|
||||
inside := \A[3] | 10
|
||||
if inside > outside then inside :=: outside
|
||||
|
||||
wsize := integer(2.2*outside)
|
||||
wsize <:= 150
|
||||
center := wsize/2
|
||||
|
||||
WOpen("size="||wsize||","||wsize,"bg=black","fg=white") | stop("Unable to open window")
|
||||
|
||||
until(points -:= 1) <= 0 do {
|
||||
x := ?(2*outside)-outside # random x
|
||||
y := ?(2*outside)-outside # and y
|
||||
if (inside <= integer(sqrt(x^2+y^2)) ) <= outside then
|
||||
DrawPoint(x + center,y + center)
|
||||
}
|
||||
WDone()
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
gen=: ({~ 100?#)bind((#~ 1=99 225 I.+/"1@:*:),/,"0/~i:15)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
'*' (<"1]15+gen '')} 31 31$' '
|
||||
|
||||
*
|
||||
*
|
||||
* * * * * *
|
||||
* * * * *
|
||||
* ***
|
||||
** * * **
|
||||
* **
|
||||
* **
|
||||
* * * *
|
||||
* * **
|
||||
* ** **
|
||||
** * ***
|
||||
* ** * *
|
||||
** *
|
||||
* ** *
|
||||
** *
|
||||
* ** *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
** *
|
||||
* **
|
||||
*
|
||||
* * * *
|
||||
* ** * * *
|
||||
* *
|
||||
**
|
||||
* * *
|
||||
** *
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
' RC Constrained Random Points on a Circle
|
||||
|
||||
nomainwin
|
||||
|
||||
WindowWidth =400
|
||||
WindowHeight =430
|
||||
|
||||
open "Constrained Random Points on a Circle" for graphics_nsb as #w
|
||||
|
||||
#w "trapclose [quit]"
|
||||
#w "down ; size 7 ; color red ; fill black"
|
||||
|
||||
for i =1 to 1000
|
||||
do
|
||||
x =int( 30 *rnd( 1)) -15
|
||||
y =int( 30 *rnd( 1)) -15
|
||||
loop until IsInRange( x, y) =1
|
||||
#w "set "; 200 +10 *x; " "; 200 - 10 *y
|
||||
next
|
||||
|
||||
wait
|
||||
|
||||
function IsInRange( x, y)
|
||||
z =sqr( x*x +y*y)
|
||||
if 10 <=z and z <=15 then IsInRange =1 else IsInRange =0
|
||||
end function
|
||||
|
||||
[quit]
|
||||
close #w
|
||||
end
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
10 MODE 1:RANDOMIZE TIME
|
||||
20 FOR J=1 TO 100
|
||||
30 X=INT(RND*30-15)
|
||||
40 Y=INT(RND*30-15)
|
||||
50 D=X*X+Y*Y
|
||||
60 IF D<100 OR D>225 THEN GOTO 40
|
||||
70 PLOT 320+10*X,200+10*Y:LOCATE 1,1:PRINT J
|
||||
80 NEXT
|
||||
90 CALL &BB06 ' wait for key press
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
sample = Take[Cases[RandomInteger[{-15, 15}, {500, 2}], {x_, y_} /; 10 <= Sqrt[x^2 + y^2] <= 15], 100];
|
||||
|
||||
Show[{RegionPlot[10 <= Sqrt[x^2 + y^2] <= 15, {x, -16, 16}, {y, -16, 16}, Axes -> True], ListPlot[sample]}]
|
||||
Loading…
Add table
Add a link
Reference in a new issue