global proc trefoilKnot() { float $startAng = 0.0; float $endAng = 2*3.14159278; float $incrAng=0.01; string $ptSeq, $ktSeq; int $k=0; for($t=$startAng;$t<=$endAng; $t+=$incrAng) { float $x = sin(3*$t); float $y = sin($t) + 2.0*sin(2.0*$t); float $z = cos($t) - 2.0*cos(2.0*$t); // print($x + " " + $y + " " + $z + "\n"); $ptSeq += " -p " + $x + " " + $y + " " + $z; $ktSeq += " -k " + $k; $k++; }// next t // close the curve /* $t=$startAng; $x = sin(3*$t); $y = sin($t) + 2.0*sin(2.0*$t); $z = cos($t) - 2.0*cos(2.0*$t); $ptSeq += " -p " + $x + " " + $y + " " + $z; $ktSeq += " -k " + $k; $k++; */ // print($ptSeq + " " + $ktSeq + "\n"); // Make a cubic curve.. print("Making a cubic curve from " + $k + " cvs..\n"); $ktSeq = "-k 0 -k 0 "; $newk= $k + 2; // how many knots $newk -= 4; // due to redundancy for($i=0;$i<$newk;$i++) { $ktSeq += "-k " + $i + " "; } $ktSeq += "-k " + ($i-1) + " -k " + ($i-1); print($ktSeq + "\n"); // $curveCreation = "curve -d 3 " + $ptSeq + " " + $ktSeq; $curveCreation = "curve -d 3 " + $ptSeq; catch(evalEcho($curveCreation)); }// trefoilKnot() trefoilKnot;