Tuesday, July 18, 2000

UnExpected Patterns : An HP48gx Experiment

Something Kooky that i’ve been playing around with for quite awhile is a collection of programs & approaches that create –roughly- “Fractal” like designs that are initiated by creating Seed Generators;
That by any lay persons estimation; Should produce random gibberish.
---
This current version plots a series of Pixels on The Display into a Spiral; As the Superstructure Template.
Because the Display is constructed from an x – y Grid, Some of the Plot Points, Particularly along the Diagonals, may be Misplaced, Forgotten or Overlaid onto previous Pixel Positions.
i’ve given a small amount of thought as to how this may be corrected, and decided that given the limitations of my Computational Platform: The HP48gx, It would be too much trouble, And cause the already, very slow Cycling Period to Creep along even slower.
So that problem is simply endured.
The pattern that this caused may be generated by creating a Seed Generator that causes All Pixel Points to Turn On. So that The Gaps can be viewed.

Then another Spiral may be created using XOR for all Points, and when these are compared, Overlaps may be Determined.
---
All programs are listed in PsuedoFlowChart Form to make is ‘Easy’ to translate them into whatever programming language that you are currently working with.
---
[ Start ]
( Although Start is listed first; you need to create a Seed Generator First, and test it. )
Create a Pictorial Area
Define The Plot Parameters to –1 to 1 along the x & y axis.
Determine The Size of One Pixel ( Width ) = ‘pixel’ Store
Pixels should be arranged with The Size of The Pictorial Area
And the Plot Parameters to be Square; i.e., Same Width as Height
Create a bunch of Variables to be used later:
pixel / 2 = ‘radius’ Store
0 = ‘angle’ Store
0 = ‘x’ Store
0 = ‘y’ Store
(0,0) = ‘last’ Store
0 = ‘length’ Store
Current Time = ‘time’ Store
Display Pictorial Area
Initiate an If Error Conditional that envelops the entire cyclic program, such that if it is artificially disturbed, The Then Consequent will be activated.
This Then Consequent will consist of Simply Ending the program prematurely,
Upon which the Terminal Instructions will be followed.
The Cyclical Core:
SINE ( angle ) * radius
COSINE ( angle ) * radius
Save as ‘x’ & ‘y’
x & y Real to Complex
Subtract from ‘last’ to Determine Distance from the Last Pixel
=+ ( Save Accumulatively into ) ‘length’ Store+
‘length’ is the Length of the Spiral as it twists around the central focii.
Save the Complex Point just created as the new ‘last’
Calculate The New ‘angle’ & ‘radius’
( radius * 2 * pi ) / pixel = ‘a1’ Store [ Temporary Variable ]
360 / a1 =+ ( Save Accumulatively into ) ‘angle’ Store+
pixel / a1 =+ ( Save Accumulatively into ) ‘radius’ Store+
Run [ SeedGenerator ]
The Seed Generator creates a 0 or 1
x & y Real to Complex
If Seed Generators Created a 1 : Plot a Pixel at ( x,y )
Continue Cycle Until radius => 1
Terminus Instructions
Current Time – time : Display Results

-
---
A completed Spiral on The HP49gx, takes significantly longer than an hour for a 131 by 131 pixel PICTURE.
-

---
[ Seed Genertor ]
This consists of a series of functions & commands that ultimately boils down to either a 0 or 1
You may use The Global Variables; radius, angle, length x, y, last or pixel...
Along with all the usual mathematical constants; such as pi, e, or i ( et. al. )
Essentially; Anything goes.
Ideally; You’re trying to create a ‘procedure’ that couldn’t possibly generate an meaningful or orderly pattern or structure...
To add to this Mayhem; i’ve created a [ Pick ] program that Picks out a digit from a Real or Otherwise Number... such that if you Ran Pick ( 4 ) on 9.43E62 : The Result would be 6
What i’ve discovered using this tool, is that given a series of numbers generated in an otherwise conventional manner, The Pick Tool will separate out ‘Layers’ of Complexity from the Resultant Numbers...???
The farther you pick digits to the Right ( Least Significant ? ) The more intricate, subtle and complex the resulting Pattern becomes.
Sample Seed Generator:
angle INVERT + length FRACTION PART [ Pick ( 3 ) ] 2 MODULUS

-
---
[ Test ]
This is intended to determine if The Seed Generator you’ve created will generate a reasonable number of both 0’s and 1’s.
The proportionality should be around 50 / 50.
i’ve also added another feature, So that it calculates (?) how long it will take to create One Animation Box.
So that; if you later wish to Use a Seed Generator to make a sereis of Plots, each Rotated by an appropriate increment, for the purpose of Animating them, this feature should give you some idea of how long it will take to make however many pictures you wish to make...
0 = ‘time’ Store
0 = ‘sum’ Store
0 to 100 Loop FOR abc
Display abc
: RAND ( Generate Random Number from 0 < difference ="+">
---
Extra Dealies...
---

[ Pix? ]
Takes ( x,y )
IF this pixel is ON,
THEN turn it off.
ELSE turn in on.
END
-
---
[ Pick ]
Picks out a Individual Digit from a Number
Number = 'n' Store
Position = 'p' Store
What is the SIGN of n = 's' Store
n MANTISSA Portion / 10
Convert to String
n EXPONTENT
Convert to String
2 12 SUB
( to remove the decimal point )
p p SUB
IF result is a Null String
THEN replace with "0"
Convert from String to Real.
Multiple by s
-
---
Make an Animation
[ Toon ]
IF count DOES NOT EQUAL 0
THEN continue from last interruption...
ELSE start a new one...
END
Continue?
Ask User if s/he like to continue with the Interrupted Version?
IF SO...
360 / frames = 'step' Store
Recall the Name of the List of Graphic Objects, where they were previously being stored... = 'save' Store
IF NOT - Start a New Animation
Ask for how many Frames are Desired = 'frames' Store
360 / frames = 'step' Store
0 = 'counter' Store
Create a Unique name for the list of Graphic Objects;
Use that Name to Store an Empty List;
Then save the Name in = 'save' Store
Create a Pictorial Area
Set x & y Plot Parameters so that each Pixel Dimension is the same as The Larger, Single Graphic Object Dimensions for each Pixel...???

So that it'll look the same as your 'Preview' Version...
The Animation Boxes, according to this thinking, will be substantially smaller than the Preview, Single Plot Version...
Set all Variables
360 / frames = 'step' Store
{ } = 'save' Store
count * step = 'begin' Store
Size of One Pixel ( Width ) = 'pixel' Store
pixel / 2 = 'radius' Store
0 = 'angle' Store
0 = 'x' Store
0 = 'y' Store
( 0,0 ) = 'last' Store
0 = 'length' Store
Current Time = 'time' Store
Create an IF ERROR structure that contains the entire core program.
If An Interrupt occurs, simply display "Aborted" Reminder
Then Proceed to Termination Instructions
LOOP begin to 359 FOR abc
Display Cleared Pictorial Area
Display Counter : frames - count
DO LOOP
SINE ( angle + abc ) * radius = 'x' Store
COSINE ( angle + abc ) * radius = 'y' Store
ABS ( ( x, y ) - last ) =+ 'length' Store+
( x,y ) = 'last' Store
( pi * radius * 2 ) / pixel = 'b1' Store ( Temp )
360 / b1 =+ 'angle' Store+
pixel / b1 =+ 'radius' Store+
Run Seed Generator
IF result = 1 THEN turn Pixel ( x,y ) to Black END
( for a reduced version .565685 represents a subset of the larger Preview Version :

Diagonal of a .4 by .4 Box )
Draw Box around Plotted Material
(.4,.4) (-.4,-.4 ) Draw Box
(.4,.4) (-.4,-.4 ) Sub Out of Pictorial Area
Recall save ( Name of List ) Save Subbed Graphic into this Name.
Reset Variables
pixel / 2 = 'radius' Store
0 = 'angle' Store
0 = 'length' Store
0 ROUNDOFF ( abc / step ) = 'count' Store
step STEP ( abc LOOP )
0 = 'count' Store
0 = 'frames' Store
IF ERROR Occurred
THEN Clear Stack : Display "Aborted" END
Current Time - time : Tag as "Elapsed Time"
-
---
[ h.m.s. ]
For the HP48gx ( et. al. ??? )
Converts a Time Format to a more Friendly Time Format
3.1206 becomes 03:12:06
-- = Program Delimiters...!!!
STD DUP XPON DUP
0 < -- DROP 0 -- IFT SWAP .00001 + ->STR "00" SWAP +
DUP "." POS
-> x \$ p
--
\$ p x 1 + DUP 2 < -- DROP 2 -- IFT - p 1 - SUB ":" \$ p 1 + DUP 1 + SUB ":" \$ p 3 + DUP 1 + SUB + + + + -- --

End