Beispiel #1
0
        public bool IntersectsSphere(Sphere sphere)
        {
            var closestPoint = new Vector3();

            // Find the point on the AABB closest to the sphere center.
            this.ClampPoint(sphere.center, closestPoint);

            // If that point is inside the sphere, the AABB and sphere intersect.
            return(closestPoint.DistanceToSquared(sphere.center) <= (sphere.radius * sphere.radius));
        }
Beispiel #2
0
        public double DistanceSqToPoint(Vector3 point)
        {
            var v1 = new Vector3();

            var directionDistance = v1.SubVectors(point, this.origin).Dot(this.direction);

            // point behind the ray

            if (directionDistance < 0)
            {
                return(this.origin.DistanceToSquared(point));
            }

            v1.Copy(this.direction).MultiplyScalar(directionDistance).Add(this.origin);

            return(v1.DistanceToSquared(point));
        }
Beispiel #3
0
 public bool ContainsPoint(Vector3 point)
 {
     return(point.DistanceToSquared(this.center) <= this.radius * this.radius);
 }