Below are the procedures for finding the distance between two vectors, and how to get the length ratio between 3 vectors (when paired with the first procedure).

///// Get the distance between 2 vectors /////

global proc float getDistance(string $startPointName, string $endPointName)
{
vector $startPoint = `xform -query -worldSpace -translation $startPointName`;
vector $endPoint = `xform -query -worldSpace -translation $endPointName`;
$distance = $startPoint – $endPoint;
return $distance;
}

///// Get the length ratio between 3 vectors /////

global proc float getLengthRatio(string $pointOne, string $startPoint, string $pointTwo)
{
float $lengthSideA = getDistance ($pointOne, $startPoint);
float $lengthSideB = getDistance ($startPoint, $pointTwo);
float $lengthSideC = getDistance ($pointOne, $pointTwo);

float $lengthSideAB = $lengthSideA + $lengthSideB ;

float $lengthRatio = $lengthSideC / $lengthSideAB ;
return $lengthRatio;
}

Share and Enjoy:
  • Digg
  • Facebook
  • Twitter
  • Google Bookmarks
  • LinkedIn
  • email
  • Print