An analytical 3D sphere defined by a center and radius. This class is mainly used as a Bounding Sphere for 3D objects.
Constructs a new sphere.
center
The center of the sphere
Default is (0,0,0).
radius
The radius of the sphere.
Default is -1.
The center of the sphere
This flag can be used for type testing.
Default is true.
The radius of the sphere.
Transforms this sphere with the given 4x4 transformation matrix.
matrix
The transformation matrix.
Returns: A reference to this sphere.
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.
point
The plane to clamp.
target
The target vector that is used to store the method's result.
Returns: The clamped point.
Returns a new sphere with copied values from this instance.
Returns: A clone of this instance.
Returns true if this sphere contains the given point inclusive of the surface of the sphere.
point
The point to check.
Returns: Whether this sphere contains the given point or not.
Copies the values of the given sphere to this instance.
sphere
The sphere to copy.
Returns: A reference to this sphere.
Returns the closest distance from the boundary of the sphere to the given point. If the sphere contains the point, the distance will be negative.
point
The point to compute the distance to.
Returns: The distance to the point.
Returns true if this sphere is equal with the given one.
sphere
The sphere to test for equality.
Returns: Whether this bounding sphere is equal with the given one.
Expands the boundaries of this sphere to include the given point.
point
The point to include.
Returns: A reference to this sphere.
Returns a serialized structure of the bounding sphere.
json
The serialized json to set the sphere from.
Returns: A reference to this bounding sphere.
Returns a bounding box that encloses this sphere.
target
The target box that is used to store the method's result.
Returns: The bounding box that encloses this sphere.
Returns true if this sphere intersects with the given box.
box
The box to test.
Returns: Whether this sphere intersects with the given box or not.
Returns true if this sphere intersects with the given plane.
plane
The plane to test.
Returns: Whether this sphere intersects with the given plane or not.
Returns true if this sphere intersects with the given one.
sphere
The sphere to test.
Returns: Whether this sphere intersects with the given one or not.
Returns true 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.
Returns: Whether this sphere is empty or not.
Makes this sphere empty which means in encloses a zero space in 3D.
Returns: A reference to this sphere.
Sets the sphere's components by copying the given values.
center
The center.
radius
The radius.
Returns: A reference to this sphere.
Computes the minimum bounding sphere for list of points. If the optional center point is given, it is used as the sphere's center. Otherwise, the center of the axis-aligned bounding box encompassing the points is calculated.
points
A list of points in 3D space.
optionalCenter
The center of the sphere.
Returns: A reference to this sphere.
Returns a serialized structure of the bounding sphere.
Returns: Serialized structure with fields representing the object state.
Translates the sphere's center by the given offset.
offset
The offset.
Returns: A reference to this sphere.
Expands this sphere to enclose both the original sphere and the given sphere.
sphere
The sphere to include.
Returns: A reference to this sphere.