Created
May 15, 2015 01:05
-
-
Save mikedotalmond/93ece6ec3e8edbc0f3e4 to your computer and use it in GitHub Desktop.
Lorenz attractor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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