Browse Source

Fix distance of sphere center to plane

As per issue #11818, use Hessian Normal Form for calculating distance of sphere center to plane when determining if the sphere intersects a plane.
Chaitanya Asawa 8 years ago
parent
commit
5806d75e8c
1 changed files with 3 additions and 10 deletions
  1. 3 10
      src/math/Sphere.js

+ 3 - 10
src/math/Sphere.js

@@ -104,21 +104,14 @@ Object.assign( Sphere.prototype, {
 		return box.intersectsSphere( this );
 
 	},
-
+	
 	intersectsPlane: function ( plane ) {
 
-		// We use the following equation to compute the signed distance from
-		// the center of the sphere to the plane.
-		//
-		// distance = q * n - d
-		//
-		// If this distance is greater than the radius of the sphere,
-		// then there is no intersection.
-
-		return Math.abs( this.center.dot( plane.normal ) - plane.constant ) <= this.radius;
+		return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;
 
 	},
 
+
 	clampPoint: function ( point, optionalTarget ) {
 
 		var deltaLengthSq = this.center.distanceToSquared( point );