aa_lorenz
//Lorenz curve generator
global proc aa_lorenz(vector $startloc, int $N){
/*
***************************************************************************
This function takes a starting position (vector) and a number of iterations
starting position gives the location of the first point of the curve, the
number of iterations specifies how long the program will loop and
the overall complexity of the curve
example:
//set up start point
$v = <<0,0,0>>;
aa_lorenz($v,1000);
************************************************************
WARNING: this script is memory intensive and too large of a
number used for iterations may cause performance trouble
************************************************************
Cory Clarke nthd.org
***************************************************************************
*/
int $i=0;
float $x0;
float $y0;
float $z0;
float $x1;
float $y1;
float $z1;
float $h = 0.01;
float $a = 10.0;
float $b = 28.0;
float $c = 8.0/3.0;
float $x0 = .01;
float $y0 = 0;
float $z0 = 0;
float $tmp;
string $lorenz;
$startstatement = "curve -d 1 -p " + $startloc.x + " " + $startloc.y + " " + $startloc.z;
$lorenz = eval($startstatement);
for($i=0;$i<$N;$i++){
//The magic happens here
$x1 = $x0 + $h * $a * ($y0 -$x0);
$tmp = ($x0 * ($b - $z0) - $y0);
$y1 = $y0 + $h * $tmp;
$z1 = $z0 + $h * ($x0 * $y0 - $c * $z0);
$x0 = $x1;
$y0 = $y1;
$z0 = $z1;
//Set point location
curve -a -p ($x0+$startloc.x) ($y0+$startloc.y) ($z0+$startloc.z) $lorenz;
/*
//for keyframing
if($i%5 == 0){
//duplicate current turtle
string $newcurve[];
string $attcommand;
string $keycommand;
$newcurve = `duplicate $lorenz`;
$keycommand = "setKeyframe " + $newcurve[0] + ".visibility";
//keyframe off at 1
currentTime 1;
$attcommand = "setAttr " + $newcurve[0] + ".visibility off";
eval($attcommand);
eval($keycommand);
//set on at current
currentTime $i;
$attcommand = "setAttr " + $newcurve[0] + ".visibility on";
eval($attcommand);
eval($keycommand);
//set back off after current
$keyframe = $i + 1;
currentTime $i;
$command = "setAttr " + $newcurve[0] + ".visibility off";
eval($attcommand);
eval($keycommand);
}
*/
}
}
print("aa_lorenz....loaded\n");
There are no threads for this page.
Be the first to start a new thread.