ReturnNVectorCOG

From scripting
Jump to: navigation, search
global proc vector ReturnNVectorCOG(vector $AllVecs[]) {
	//Author Nick Pisca 0001d 2010
	//$AllVecs[0]=<<0,0,0>>;$AllVecs[1]=<<1,-1,0>>;$AllVecs[2]=<<1,0,0>>;$AllVecs[3]=<<0,0,2>>;
	vector $TempVec = <<0,0,0>>;
	if (size($AllVecs) != 0 ) {
		for ($i=0;$i<size($AllVecs);$i++) {
			$TempVec = $TempVec + $AllVecs[$i];
		}
		$TempVec = $TempVec / size($AllVecs); 
	}
	return $TempVec;
}



More information on vectors and vector mathematics, read pages 14-16, 20-21 in YSYT.