Skip to content

Instantly share code, notes, and snippets.

@mikedotalmond
Created May 15, 2015 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikedotalmond/93ece6ec3e8edbc0f3e4 to your computer and use it in GitHub Desktop.
Save mikedotalmond/93ece6ec3e8edbc0f3e4 to your computer and use it in GitHub Desktop.
Lorenz attractor
package;
/**
* ...
* @author Mike Almond - https://github.com/mikedotalmond
*/
class Lorenz {
public var sigma:Float;
public var rho:Float;
public var beta:Float;
public var x(default, null):Float;
public var y(default, null):Float;
public var z(default, null):Float;
public function new() {
sigma = 10.0;
rho = 28.0;
beta = 8 / 3;
x = 1; y = 1; z = 1;
}
public function step(dt:Float=1/120) {
x = x + dt * (sigma * (y - x));
y = y + dt * (x * (rho - z) - y);
z = z + dt * (x * y - beta * z);
#if debug
trace(x, y, z);
#end
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment