# Henon Attractor in JRubyArt

**URL:** <https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937>\
**Category:** Gallery\
**Created:** [January 9, 2021, 10:35pm UTC](https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937 "2021-01-09T22:35:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [January 9, 2021, 10:35pm UTC](https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937/1 "2021-01-09T22:35:36Z")

</div>

Sketch started from Atom my ide of choice with JRubyArt

```ruby
ALPHA = 1.4
BETA = 0.3

attr_reader :x, :y

def setup
  sketch_title 'Henon Attractor'
  frame_rate(360)
  background(0)
  @x = map1d(rand, 0..1.0, -0.1..0.1)
  @y = map1d(rand, 0..1.0, -0.1..0.1)
end

def draw
  stroke(255)
  stroke_weight 2
  translate(width / 2, height / 2)
  nextX = 1 - ALPHA * x**2 + y
  nextY = BETA * x
  @x = nextX
  @y = nextY
  sx = map1d(x, -1.5..1.5, -250..250)
  sy = map1d(y, -0.5..0.5, -250..250)
  point(sx, sy)
end

def settings
  size(500, 500)
  smooth 4
end

```

 ![henon_attractor](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/993432a21101bba9064d1d397655a7cfa55f7d92.jpeg)

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [January 10, 2021, 12:05am UTC](https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937/2 "2021-01-10T00:05:33Z")

</div>

Nothing beats Peter de Jong attractors

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [January 10, 2021, 12:19pm UTC](https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937/3 "2021-01-10T12:19:41Z")

</div>

Nice! Learning all the time.

> **[Hénon map](https://en.wikipedia.org/wiki/H%C3%A9non_map)**
>
> The Hénon map , sometimes called Hénon-Pomeau attractor/map, is a discrete-time dynamical system. It is one of the most studied examples of dynamical systems that exhibit chaotic behavior. The Hénon map takes a point (xn, yn) in the plane and maps it to a new point
> The map depends on two parameters, a and b, which for the classical Hénon map have values of a = 1.4 and b = 0.3. For the classical values the Hénon map is chaotic. For other values of a and b the map may be chaotic, intermittent, ...

A P5.js version

https://editor.p5js.org/noelpil/present/2pl2GJRy9

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [January 10, 2021, 1:30pm UTC](https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937/4 "2021-01-10T13:30:34Z")

</div>

> [@micycle](#):
>
> Nothing beats Peter de Jong attractors

These are really good!  
[http://paulbourke.net/fractals/peterdejong/](http://paulbourke.net/fractals/peterdejong/)

Just a [point attempt](https://editor.p5js.org/noelpil/sketches/mYzcZq5XX).

https://editor.p5js.org/noelpil/present/mYzcZq5XX

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [January 11, 2021, 1:50pm UTC](https://discourse.processing.org/t/henon-attractor-in-jrubyart/26937/5 "2021-01-11T13:50:12Z")

</div>

Here’s my JRubyArt version

```ruby
attr_reader :x, :y, :b, :timer

B = -2.3

def settings
  size(450, 450)
end

def setup
  sketch_title 'De Jong Attractor'
  @x = @y = 0
  @timer = 0
  stroke(255)
  stroke_weight(3)
end

def draw
  @timer += 0.01
  background(0, 0, 200)
  ac = 3 * cos(timer)
  d = 3 * sin(timer)
  calculate_points ac, d
end

def calculate_points(ac, d)
  3_000.times do
    xn = x
    yn = y
    @x = sin(ac * yn) - cos(B * xn)
    @y = sin(ac * xn) - cos(d * yn)
    point(width / 2 + 100 * x, height / 2 + 100 * y)
  end
end

```
