/*
script om rechte lijnen tussen 2 curves te maken
Sander Mulders
(c)2006
XXL-workshop
*/

int $aantal = 20;

string $lijn;

proc rebuildCurveZeroToOne ( string $object ) {
	
	int $degree;
	$degree = `getAttr ($object+".degree")`;
	
	rebuildCurve -replaceOriginal 1 -end 1 -degree $degree -keepRange 0 -keepControlPoints 1 $object;
}

proc float[] parameterDivision ( int $numspans ) {
	float $distance = 1 / float($numspans);	
	float $pos = 0;
	float $result[];
	int $num = 0;
	
	while ( $pos <= 1 ) {
		$result[$num] = $pos;
		$num++;
		$pos = $num * $distance;
	}
	return $result;
}


  // retrieve the selected curve
  string $objects[] = `ls -sl`;
  string $curve1 = $objects[0];
  string $curve2 = $objects[1];
  
  print $curve1;
  print $curve2;
  
  rebuildCurveZeroToOne($curve1);
  rebuildCurveZeroToOne($curve2);
  
  float $curvePoints[] = parameterDivision($aantal);
  
  for ( $parameter in $curvePoints) {
	  // achterhaal de world-coordinaten van de punten op elk van de drie curves
	$pos1 = `pointOnCurve -position -pr $parameter $curve1`;
	$pos2 = `pointOnCurve -position -pr $parameter $curve2`;
	
	// teken een lijn tussen pos1 en pos 2
	$lijn = `curve -degree 1 -p $pos1[0] $pos1[1] $pos1[2] -p $pos2[0] $pos2[1] $pos2[2]`;
	
  }
