home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
graphics
/
fractal_1
/
!Fractal
/
Help
/
Quaternion
< prev
next >
Wrap
Text File
|
1996-10-09
|
2KB
|
46 lines
Quaternion : Invented by William Hamilton, 1843
----------
A Quaternion is a 4d equivalent of a complex number, written as:
Q = a+bi+cj+dk
where i, j and k are imaginary numbers. They are used here in a similar way
to Julia sets with Q -> Q²+q where q is a quaternion constant, made up of
q0, q1, q2 and q3 in this routine. The routine maps out a 2-dimensional
slice using x=a and y=c, with the values of b and d being set to choose
which slice of the 4d plane we are drawing.
The initial values chosen for q0 and q2 are the same as those for the Julia
Set, and you will note the image is superficially very similar. Changing q1,
q3, b or d however allows different planes to be examined, giving a great
area to investigate.
As with the Julia set, the best way to choose values for q0 and q2 is from
the Mandelbrot set - use the Quaternion menu option to pick a point from
near the boundary.
The menu options operate in the same way as for the Julia set.
Algorithm
---------
A 32 bit and floating point version are provided, but both will be slower
than Julia's due to the extra multiplications.
For each pixel we calculate the a (x) & c (y) value and then iterate. The
colour is the iteration number unless Q²>4.0, when we set the colour to 0
(or as set by the Interior menu option).
iter=0;
repeat
iter + 1
if (a²+b²+c²+d²>4) then escape
new_a=a²-b²-c²-d²+q0
b=2*a*b+q1
c=2*a*c+q2
d=2*a*d+q3
a=new_a
until iter>=max_iter
Notes: It is possible to use other functions such as Q->Q³+q as done for
Mandelbrot's. Also it is possible to produce a 3d mapping, though a lot of
the swirling detail apparently is lost. Iterating the function Mandelbrot
style gives a variation on the Mandelbrot shape.