Jump to content

Fractals/Hopalong

From Wikibooks, open books for an open world

Hopalong orbit-fractals.

  • the Martin-Attractors: were discovered by Barry Martin[1]
  • Hopalong: an image is built of points hopping along on an elliptical path starting from one point in the center.

History

[edit | edit source]
  • Hopalong orbits were discovered by Barry Martin from the Aston University, Birmingham.
  • A.K. Dewdney presented the Hopalongs in the magazine "Scientific American" (1986)


Algorithm

[edit | edit source]

An image is calculated using three parameters: a, b and c.



Where

  • a, b and c are constants which, by default are initialised to -55, -1 and -42 respectively[2]
  • ABS is the absolute value function
  • SIGN(x) is the same as x/ABS(x). If x>0 then SIGN(x) = 1, if x<0 then SIGN(x) = −1 and if x = 0 then the result of SIGN(x) is zero, too.
  • The color is changed every 2000 dots, until the 10 predefined colors are used, then the colors are repeated.

Devaney's program

INPUT num
INPUT a, b, c
x = 0
y = 0
PLOT(x, y)
FOR i = 1 TO num
xx = y - SIGN(x) * [ABS(b*x - c)]^0.5
yy = a - x
x = xx
y = yy

Implementations

[edit | edit source]


From Barry Martin, here with code for two variants from François Pacull:

@jit(nopython=True)
def Hopalong1(x, y, a, b, c, *o):
    return y - sqrt(fabs(b * x - c)) * np.sign(x), \
           a - x
@jit(nopython=True)
def Hopalong2(x, y, a, b, c, *o):
    return y - 1.0 - sqrt(fabs(b * x - 1.0 - c)) * np.sign(x - 1.0), \
           a - x - 1.0

plot(Hopalong1)

OpenProcessing code by Naoki Tsutae:

x=0
a=2,b=1,c=0
t=0
setup=_=>{
  createCanvas(800,800)
  background(0)
  noStroke()
}
draw=_=>{
  t+=1
  translate(width*.45,height*.45)

  y=sin(t/60) 
  for(i=3e3;i--;){
    newx=y-1-sqrt(abs(b*x-1-c))*Math.sign(x-1)
    newy=a-x-1
    x=newx
    y=newy
    fill(map(sin(x+t),-1,1,0,256),map(sin(y+t),-1,1,0,256),map(sin(x+y+t),-1,1,0,256))
    rect(x*100,y*100,2,2)
  } 
}

References

[edit | edit source]
  1. Hopalong by Ulrich Schwebinghaus
  2. hopalong fractal by James Henstridge