proc vector vectorTest_Dark(vector $v1, vector $v2,vector $v3){
vector $v21 = $v2-$v1;
return $v1+dot(($v3-$v1),$v21)*$v21/dot($v21,$v21);
}
proc vector vectorTest_4i4ikov(vector $v1, vector $v2,vector $v3){
vector $v21 = $v2-$v1;
vector $v13 = $v1-$v3;
vector $v23 = $v2-$v3;
float $k = (($v13*$v13)-($v23*$v23))/(2*$v21*$v21) + 0.5;
return $v2*$k+$v1*(1-$k);
}
print("/* Maya "+`about -v`+" x"+(`about -x64`?"64":"32")+"\n");
print("--------------- "+"Check\n");
vector $v1 = <<5.111 , -2.046, -1.956>>;
vector $v2 = <<-5.419 , -0.070 , -1.225>>;
vector $v3 = << -0.246 , 0 , -6.764>>;
print(vectorTest_Dark($v1,$v2,$v3)+"\n");
print(vectorTest_4i4ikov($v1,$v2,$v3)+"\n");
print("delta check: "+(vectorTest_Dark($v1,$v2,$v3)-vectorTest_4i4ikov($v1,$v2,$v3)+"\n"));
int $N = 1000000;
print("--------------- "+"Bench <MEL> "+$N+"\n");
$M = $N/100000; if ($M!=1) print("bench time magnitude correction: "+$M+"\n");
for ($n=0; $n<4; $n++){
$startTime = `timerX`;
for ($i=1; $i<$N; $i++) vectorTest_Dark($v1/$i,$v2/$i,$v3/$i);
$bench = `timerX -startTime $startTime`;
print ("Dark "+$bench*10/$M+"\n");
$startTime = `timerX`;
for ($i=1; $i<$N; $i++) vectorTest_4i4ikov($v1/$i,$v2/$i,$v3/$i);
$bench = `timerX -startTime $startTime`;
print ("4i4ikov "+$bench*10/$M+"\n");
}print "*/\n";