Share Pastebin
Guest
Public paste!

bitStudent

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 1.03 KB | Hits: 15 | Expires: Never
Copy text to clipboard
  1. // fixed!
  2. proc float getLinePlaneAngle(string $planeName, string $nameLoc1, string $nameLoc2)
  3. {
  4.         float $loc1[] = `xform -ws -q -t $nameLoc1`;
  5.         float $loc2[] = `xform -ws -q -t $nameLoc2`;
  6.        
  7.         print ("\n locators info \n");
  8.         print $loc1;
  9.         print $loc2;
  10.  
  11.         // find locator vector
  12.         float $vLoc[3];
  13.         $vLoc[0] = $loc2[0] - $loc1[0];  
  14.         $vLoc[1] = $loc2[1] - $loc1[1];  
  15.         $vLoc[2] = $loc2[2] - $loc1[2];
  16.  
  17.         float $vNorm[] = `getNormalVector($planeName)`;
  18.  
  19.         float $magLoc = `sqrt( (($vLoc[0])*($vLoc[0])) + (($vLoc[1])*($vLoc[1])) +(($vLoc[2])*($vLoc[2])))`;
  20.         print $magLoc;
  21.  
  22.         float $magNorm = `sqrt( (($vNorm[0])*($vNorm[0])) + (($vNorm[1])*($vNorm[1])) +(($vNorm[2])*($vNorm[2])))`;
  23.         print ("\n");
  24.         print $magNorm;
  25.  
  26.         float $tempAngle = acosd( ((($vLoc[0])*($vNorm[0]))+ (($vLoc[1])*($vNorm[1])) + (($vLoc[2])*($vNorm[2]))) / ($magLoc * $magNorm));
  27.         print"\n temp angle: ";
  28.         print $tempAngle;
  29.  
  30.         float $realAngle = 90 - $tempAngle;    
  31.  
  32.         print"\n real angle: ";
  33.         print $realAngle;
  34.        
  35.         //returns float angle
  36.         return $realAngle;
  37. }