Explorar o código

Math: Less mormalization error in Quaternion.slerp.

tschw %!s(int64=9) %!d(string=hai) anos
pai
achega
cc82a2a696
Modificáronse 2 ficheiros con 2 adicións e 3 borrados
  1. 1 1
      src/math/Quaternion.js
  2. 1 2
      test/unit/math/Quaternion.js

+ 1 - 1
src/math/Quaternion.js

@@ -441,7 +441,6 @@ THREE.Quaternion.prototype = {
 
 		}
 
-		var halfTheta = Math.acos( cosHalfTheta );
 		var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta );
 
 		if ( Math.abs( sinHalfTheta ) < 0.001 ) {
@@ -455,6 +454,7 @@ THREE.Quaternion.prototype = {
 
 		}
 
+		var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
 		var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
 		ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
 

+ 1 - 2
test/unit/math/Quaternion.js

@@ -342,8 +342,7 @@ function slerpTestSkeleton( doSlerp, maxError ) {
 
 test( "slerp", function() {
 
-	var ErrorMargin = Number.EPSILON * 64; // probably improvable
-	slerpTestSkeleton( doSlerpObject, ErrorMargin );
+	slerpTestSkeleton( doSlerpObject, Number.EPSILON );
 
 } );