Curves
Generate A Curve Between 2 Designated Points
The Goal: to generate curves which begin from the points of other
curves to form a series of branches. This is the first in
a series of exercises in developing a way to create the branching
effect. The images demonstrate multiple executions of code
to illustrate randomness in the curves.
$lineType = 3

$lineType = 1

float $lineType = 3;
string $line = "curve -d $lineType ";
vector $pnts[];
float $x1 = -1;
float $y1 = 0;
float $z1 = 0;
float $x2 = 2;
float $y2 = 0;
float $z2 = 0;
float $num_pnts = 6;
float $xspan = ($x2 - $x1)/($num_pnts -1);
float $yspan = ($y2 - $y1)/($num_pnts -1);
float $zspan = ($z2 - $z1)/($num_pnts -1);
//Get the points for a straight line
for ($i = 0; $i < $num_pnts; $i++) {
$pnts[$i] = <<$x1, $y1, $z1>>;
$x1 += $xspan;
$y1 += $yspan;
$z1 += $zspan;
}
//Randomize the points
for ($i = 1; $i < ($num_pnts-1); $i++) {
$pnts[$i] += << rand(-.5,.5),
rand(-.5,.5),
rand(-.5,.5)>>;
}
//Generate the line
for ($i = 0; $i < $num_pnts; $i++) {
$line += " -p " + $pnts[$i];
}
eval($line);
Random Curves from a Designated Point
Bezier Curves

Linear Curves

proc buildCurve(float $length) {
vector $pntsB[];
float $x = -1;
float $y = 0;
float $z = 0;
string $lineB = "curve -d 1 ";
for ($i = 01; $i < $length; $i++) {
$pntsB[$i] = <<$x, $y, $z>>;
$x += rand(-1,1);
$y += rand(-1,1);
$z += rand(-1,1);
$lineB += " -p " + $pntsB[$i];
}
eval($lineB);
} buildCurve(6);
|