# Sphere

A sphere defined by a center and radius.

## Constructor

### Sphere(center : Vector3, radius : Float)

center - center of the sphere. Default is a Vector3 at (0, 0, 0).

Creates a new Sphere.

## Properties

### # .center : Vector3

A Vector3 defining the center of the sphere. Default is (0, 0, 0).

The radius of the sphere. Default is 0.

## Methods

### # .applyMatrix4 (matrix : Matrix4) : Sphere

matrix - the Matrix4 to apply

Transforms this sphere with the provided Matrix4.

### # .clampPoint (point : Vector3, target : Vector3) : Vector3

point - Vector3 The point to clamp.
target — the result will be copied into this Vector3.

Clamps a point within the sphere. If the point is outside the sphere, it will clamp it to the closest point on the edge of the sphere. Points already inside the sphere will not be affected.

### # .clone () : Sphere

Returns a new sphere with the same center and radius as this one.

### # .containsPoint (point : Vector3) : Boolean

point - the Vector3 to be checked

Checks to see if the sphere contains the provided point inclusive of the surface of the sphere.

### # .copy (sphere : Sphere) : Sphere

Copies the values of the passed sphere's center and radius properties to this sphere.

### # .distanceToPoint (point : Vector3) : Float

Returns the closest distance from the boundary of the sphere to the point. If the sphere contains the point, the distance will be negative.

### # .isEmpty () : Boolean

Checks to see if the sphere is empty (the radius set to a negative number).
Spheres with a radius of 0 contain only their center point and are not considered to be empty.

### # .makeEmpty () : Sphere

Makes the sphere empty by setting center to (0, 0, 0) and radius to -1.

### # .equals (sphere : Sphere) : Boolean

Checks to see if the two spheres' centers and radii are equal.

### # .getBoundingBox (target : Box3) : Box3

target — the result will be copied into this Box3.

Returns aMinimum Bounding Box for the sphere.

### # .intersectsBox (box : Box3) : Boolean

box - Box3 to check for intersection against.

Determines whether or not this sphere intersects a given box.

### # .intersectsPlane (plane : Plane) : Boolean

plane - Plane to check for intersection against.

Determines whether or not this sphere intersects a given plane.

### # .intersectsSphere (sphere : Sphere) : Boolean

sphere - Sphere to check for intersection against.

Checks to see if two spheres intersect.

### # .set (center : Vector3, radius : Float) : Sphere

center - center of the sphere.

Sets the center and radius properties of this sphere.
Please note that this method only copies the values from the given center.

### # .setFromPoints (points : Array, optionalCenter : Vector3) : Sphere

points - an Array of Vector3 positions.
optionalCenter - Optional Vector3 position for the sphere's center.

Computes the minimum bounding sphere for an array of points. If optionalCenteris given, it is used as the sphere's center. Otherwise, the center of the axis-aligned bounding box encompassing points is calculated.

### # .translate (offset : Vector3) : Sphere

Translate the sphere's center by the provided offset Vector3.