Softology's Blog

Fractals, Chaos Theory, Science, Space, etc

Wada Basins

leave a comment »

Wada Basins are fractal patterns that emerge from repeated reflections between closely nested spheres. The simplest and most well known version is to use 4 spheres stacked into a pyramid shape (3 forming the base triangle supporting the 4th sitting on top of them). When you look into one of the gaps you get Wada Basin patterns.

This sort of setup is ideal for ray tracing. I recently started to code up a simple ray tracer and this is the initial result of simulating a Wada Basin setup. 4 reflective spheres colored red, green, blue and white with a single point light source.

Ray traced Wada Basins

Paul Bourke has more information and samples here.
Miqel.com also has some nice images of both real and raytraced Wada Basins here.

Next Christmas, grab 4 sphere shaped ornaments off the tree and make your own fractal patterns.

Jason.

Written by softologyblog

October 27, 2009 at 1:35 pm

Posted in Chaos

3D Strange Attractors

leave a comment »

After some experimenting, I came up with the following 5 new formulas for generating 3D strange attractors. They all use SIN and COS like Cliff Pickover did when he was creating strange attractors.

All of these formulas were found by trial and error of changing and trying new formulas. In the future it would be interesting to use a genetic/evolutionary system of randomizing formulas and trying to find interesting results automatically.

The x,y and z variables are intialized to 0. Newx, newy and newz are temporary variables to hold the new x,y and z values until the new point is calculated. The parameters in italics a to i are floating point values in the range of -1 to +1 that alter/control the resulting image.

These sample images contain up to one billion plotted points to smooth them out. Each pixel is an average of a super sampled 3×3 grid to help remove aliasing (this is similar to rendering the image at 9 times the size and then downsizing it in an image processing application). The first two samples of each formula are rendered using a z-buffer technique to give them a solid appearance. The third sample of each formula is rendered using an accumulation buffer that shades the pixels based on the number of times each pixel is hit which allows you to see the internal structure of the attractor.

Rampe1 Attractor
newx=z*sin(a*x)+cos(b*y)
newy=x*sin(c*y)+cos(d*z)
newz=y*sin(e*z)+cos(f*x)

rampe1_01

rampe1_02

rampe1_05

Rampe2 Attractor
newx=z*sin(a*x)+arccos(b*y)
newy=x*sin(c*y)+arccos(d*z)
newz=y*sin(e*z)+arccos(f*x)

rampe2_01

rampe2_02

rampe2_03

Rampe3 Attractor
newx=x*z*sin(a*x)-cos(b*y)
newy=y*x*sin(c*y)-cos(d*z)
newz=z*y*sin(e*z)-cos(f*x)

rampe3_01

rampe3_02

rampe3_03

Rampe4 Attractor
newx=x*sin(a*x)+cos(b*y)
newy=y*sin(c*y)+cos(d*z)
newz=z*sin(e*z)+cos(f*x)

rampe4_01

rampe4_02

rampe4_03

Rampe5 Attractor
newx=y*sin(a*x)+cos(b*y)+sin(c*z)
newy=z*sin(d*x)+cos(e*y)+sin(f*z)
newz=x*sin(g*x)+cos(h*y)+sin(i*z)

rampe5_01

rampe5_02

rampe5_03

All of the above images were created using Visions Of Chaos.

Jason.

Written by softologyblog

October 19, 2009 at 1:24 pm

Posted in Chaos

Web Camera Viewer

leave a comment »

Web Camera Viewer screenshot

Web Camera Viewer has been updated. All of the dead cameras have been removed and it now supports the correct theme support under Windows XP, Vista and 7.

Supports creating time lapse movies and other features to easily manage hundreds of webcams.

Jason.

Written by softologyblog

October 13, 2009 at 5:53 pm

Posted in Softology

Controlling MIDI Output with Delphi

leave a comment »

I found it difficult when I first started trying MIDI programming to get any decent documentation or a simple snippet of code to turn MIDI notes on and off. This Delphi source code allows you to control the Windows MIDI notes from within a Delphi application. Create a new unit _midi.pas and copy and paste the code contents below into it.

This allows single or multiple notes to be played. Using these simple commands (all based on the mmsystem.pas unit that talks to the windows MMSYSTEM.DLL) is how I handled all the MIDI in GBK.

Hopefully this helps anyone who is looking for a simple way to get MIDI support into their Delphi application.


{
Instructions:
1) Call OpenMidiOut before playing any notes
2) Call TurnOnMidiNote to start playing a note
   This can be called multiple times for "simultaneous" notes
3) Add some sort of delay for the notes. ie sleep() etc
4) Call TurnOffMidiNote to stop playing all playing note(s)
5) When done, call CloseMidiOut to allow other apps to access the midi port
}

unit _midi;

interface

uses Windows,Messages,SysUtils,Classes,Graphics,Controls,
     Forms,Dialogs,StdCtrls,mmsystem,registry;

function MidiAvailable:boolean;
procedure OpenMidiOut(ParentForm:TForm);
procedure TurnOnMidiNote(Note,Instrument,Volume,Channel,Panning:byte);
procedure TurnOffSingleMidiNote(Note,Channel:byte);
procedure TurnOffAllMidiNotes;
procedure CloseMidiOut;

var MidiOutDev:HMIDIOUT; //global handle to midi device
    MidiOpen:boolean; //refer to this variable to see if a midi device is currently open

implementation

function MidiAvailable:boolean;
begin
     If (midiOutGetNumDevs()=0) then MidiAvailable:=false
     else MidiAvailable:=true;
end;

procedure OpenMidiOut(ParentForm:TForm);
begin
     midiOutOpen(@MidiOutDev,MIDI_MAPPER,ParentForm.Handle,0,CALLBACK_WINDOW);
     MidiOpen:=true;
end;

//note = 0-127 - see table at bottom for values
//inst = 0-127 - see table at bottom for values
//vol  = 0-127
//chan = 0-15
//pan  = 0-127 0=only left 63=both 127=only right
procedure TurnOnMidiNote(Note,Instrument,Volume,Channel,Panning:byte);
begin
     //tell midi device which instrument or patch to use
     midiOutShortMsg(MidiOutDev,MAKEWORD($C0 OR Channel,Instrument));

     //panning
     midiOutShortMsg(midioutdev,strtoint('$'+inttohex(panning,2)+'0AB'+inttohex(channel,1)));

     //tell midi device what note to play
     midiOutShortMsg(MidiOutDev,MAKELONG(MAKEWORD($90 or Channel,Note),MAKEWORD(Volume,0)));
end;

procedure TurnOffSingleMidiNote(Note,Channel:byte);
begin
     //tell midi device what note to play
     midiOutShortMsg(MidiOutDev,MAKELONG(MAKEWORD($80 or Channel,Note),MAKEWORD(0,0)));
end;

procedure TurnOffAllMidiNotes;
begin
     {Reset the midi device}
     midiOutReset(MidiOutDev);
end;

procedure CloseMidiOut;
begin
     {Close the midi device so anyone else can use it.}
     midiOutClose(MidiOutDev);
     MidiOpen:=false;
end;

{
Oct#  C   C#  D   D#  E   F   F#  G   G#  A   A#  B
 -1   0   1   2   3   4   5   6   7   8   9   10  11
  0   12  13  14  15  16  17  18  19  20  21  22  23
  1   24  25  26  27  28  29  30  31  32  33  34  35
  2   36  37  38  39  40  41  42  43  44  45  46  47
  3   48  49  50  51  52  53  54  55  56  57  58  59
  4   60  61  62  63  64  65  66  67  68  69  70  71
  5   72  73  74  75  76  77  78  79  80  81  82  83
  6   84  85  86  87  88  89  90  91  92  93  94  95
  7   96  97  98  99  100 101 102 103 104 105 106 107
  8   108 109 110 111 112 113 114 115 116 117 118 119
  9   120 121 122 123 124 125 126 127
}

{
Acoustic Grand Piano
Bright Acoustic Piano
Electric Grand Piano
Honky-tonk Piano
Electric Piano 1
Electric Piano 2
Harpsichord
Clavi
Celesta
Glockenspiel
Music Box
Vibraphone
Marimba
Xylophone
Tubular Bells
Dulcimer
Drawbar Organ
Percussive Organ
Rock Organ
Church Organ
Reed Organ
Accordion
Harmonica
Tango Accordion
Acoustic Guitar (nylon)
Acoustic Guitar (steel)
Electric Guitar (jazz)
Electric Guitar (clean)
Electric Guitar (muted)
Overdriven Guitar
Distortion Guitar
Guitar harmonics
Acoustic Bass
Electric Bass (finger)
Electric Bass (pick)
Fretless Bass
Slap Bass 1
Slap Bass 2
Synth Bass 1
Synth Bass 2
Violin
Viola
Cello
Contrabass
Tremolo Strings
Pizzicato Strings
Orchestral Harp
Timpani
String Ensemble 1
String Ensemble 2
SynthStrings 1
SynthStrings 2
Choir Aahs
Voice Oohs
Synth Voice
Orchestra Hit
Trumpet
Trombone
Tuba
Muted Trumpet
French Horn
Brass Section
SynthBrass 1
SynthBrass 2
Soprano Sax
Alto Sax
Tenor Sax
Baritone Sax
Oboe
English Horn
Bassoon
Clarinet
Piccolo
Flute
Recorder
Pan Flute
Blown Bottle
Shakuhachi
Whistle
Ocarina
Lead 1 (square)
Lead 2 (sawtooth)
Lead 3 (calliope)
Lead 4 (chiff)
Lead 5 (charang)
Lead 6 (voice)
Lead 7 (fifths)
Lead 8 (bass + lead)
Pad 1 (new age)
Pad 2 (warm)
Pad 3 (polysynth)
Pad 4 (choir)
Pad 5 (bowed)
Pad 6 (metallic)
Pad 7 (halo)
Pad 8 (sweep)
FX 1 (rain)
FX 2 (soundtrack)
FX 3 (crystal)
FX 4 (atmosphere)
FX 5 (brightness)
FX 6 (goblins)
FX 7 (echoes)
FX 8 (sci-fi)
Sitar
Banjo
Shamisen
Koto
Kalimba
Bag pipe
Fiddle
Shanai
Tinkle Bell
Agogo
Steel Drums
Woodblock
Taiko Drum
Melodic Tom
Synth Drum
Reverse Cymbal
Guitar Fret Noise
Breath Noise
Seashore
Bird Tweet
Telephone Ring
Helicopter
Applause
Gunshot
}

end.

I have been using Delphi for years for programming all the applications on Softology. I highly recommend it to anyone interested in programming. If they would only release a cheap/free entry level version for newcomers to play with.

Jason.

Written by softologyblog

September 30, 2009 at 2:27 pm

Posted in Delphi

Platonic Solid Subdivisions

leave a comment »

Michael Hansmeyer has some amazing images based on modifications of subdivisions of platonic solids.
Very inspiring.



Full gallery can be seen here.

Jason.

Written by softologyblog

September 18, 2009 at 9:22 am

Posted in Chaos

Aging Hubble given a major overhaul and extended life

leave a comment »

The Hubble Space Telescope recently had an overhaul with new equipment and cameras. The results are stunning.

Latest images from refurbished hubble

More information here.

For an idea of just how good the new equipment is have a look at this before and after
Before and after
courtesy of the Universe Today Blog post here.

NASA has had funding issues for a while now, but missions and successes like this reach out to the general public and hopefully inspire a whole new generation of future astronomers to get into science.

Jason.

Written by softologyblog

September 11, 2009 at 2:50 pm

Posted in Space

Anagram Generator now freeware

leave a comment »

I have now changed the licensing for my Anagram Generator program to freeware. If you have any interest in Anagrams, check it out. Runs under XP, Vista and Windows 7.

Anagram Generator screen shot

Features of Anagram Generator include;
1. Creates anagrams and lexigrams.
2. Generates reverse dictionaries.
3. Word search function allows wildcard search on dictionary.
4. Allows you to see if your phone number spells anything interesting.
5. Searches for palindromes.
6. Search for words that rhyme with other words. Ideal for song writers, musicians and poets.
7. Includes English, French, German, Italian, Japanese, Dutch and Spanish dictionaries.
8. Solves Jumble puzzles.
9. Saves all results as txt files for future viewing/editing/printing.
10. Non-encrypted dictionaries allow full customisation of words if required.
11. Manually edited English dictionary trimmed to generate interesting anagrams at a much faster speed.

Jason.

Written by softologyblog

September 10, 2009 at 10:25 am

Posted in Softology

Universe related websites

leave a comment »

Here are a few of the more interesting space related blogs and websites I frequently read. All have some inspiring and mind-blowing articles and images.

Websites

Astronomy Picture Of The Day. Also be sure to check out their archive for 14 years worth of images.
NASA
NASA Cassini Equinox Mission. Images of Saturn and its moons.
NASA JPL MER. Images from the Mars rovers.
Mars Reconnaissance Orbiter. Superb high res pictures of the surface of Mars from orbit.
STSI. Latest info and images from the Hubble Space Telescope.
TRACE and SOHO. Images of our nearest star.

Blogs

Phil Plait’s Bad Astronomy
Universe Today

Jason.

Written by softologyblog

September 10, 2009 at 9:01 am

Posted in Space

Genetic Art – Part 5

leave a comment »

I have written a quick PDF paper describing the processes I have used for creating Genetic Art.

Here are some examples of Genetic Art animations on YouTube. If you have the bandwidth definitely check out the HD versions as they are far superior and show much more detail.

Jason.

Written by softologyblog

August 7, 2009 at 11:51 am

Posted in Genetic Art

Genetic Art – Part 4

leave a comment »

After some research into binary expression trees, infix, prefix and postfix I was able to create a new Genetic Art 3 mode for Visions Of Chaos.

Basing the image formulas on expression trees allows far more complex images to be bred using mutations, combinations and crossover.

Too see a full range of images this new Genetic Art method is capable of see this flickr set.

Here are a few thumbnails and the formulas that create them.

Sample 31
((((y+x)*arctan((x*round(pi))))%((((y+x)*arctan((y/int(pi))))-cos((x+5.4)))%(((y%y)-y)%(2.7*4.5))))+((((y+x)*arctan((y/int(pi))))-cos((x+5.4)))%(((y%y)-y)%(2.7*4.5))))

Sample 34
(((pi%4.2)*arctan(((x*y)+sin((y*tan(7.2))))))*((((pi%4.2)*arctan(((x*y)+sin((y*tan(7.2))))))%(((y-sin(y))%(x*sqrt(pi)))-(((1.2-pi)%sgn((x/4.2)))*abs((x+y)))))-((pi%4.2)*arctan(((x*y)+sin((y*tan(7.2))))))))

Sample 6
(((((1.3/0.9)+sin((y*x)))%(((1.3/0.9)+sin((y*x)))%(((y*0.5)%6.5)-cos((x%(y-sqr(pi)))))))+((((1.3/0.9)+sin((y*x)))-(((1.3/0.9)+sin((y*x)))%(((y*0.5)%6.5)-cos((x%(y-sqr(pi)))))))*(((1.3/0.9)+sin((y*x)))%(((y*0.5)%6.5)-cos((x%(y-sqr(pi))))))))+((((1.3/0.9)+sin((y*x)))%(((1.3/0.9)+sin((y*x)))%(((y*0.5)%6.5)-cos((x%(y-sqr(pi)))))))+((((1.3/0.9)+sin((y*x)))-(((1.3/0.9)+sin((y*x)))%(((y*0.5)%6.5)-cos((x%(y-sqr(pi)))))))%(((y+round(pi))%(x+cos(y)))+int(((x/7.4)*(y-(7.4*sin(7.2)))))))))

There is also a high-def video of Genetic Art animations here. The animations change the digit nodes in the expression tree slightly over each frame.

Jason.

Written by softologyblog

July 26, 2009 at 5:30 pm

Posted in Genetic Art