Home Reference Source
import {Sphere} from 'math-ds'
public class | source

Sphere

A sphere.

Constructor Summary

Public Constructor
public

constructor(center: Vector3, radius: Number)

Constructs a new sphere.

Member Summary

Public Members
public

The center.

public

The radius.

Method Summary

Public Methods
public

Clamps the given point to this sphere.

public

Clones this sphere.

public

Checks if the given point lies inside this sphere.

public

Copies the given sphere.

public

Calculates the distance from this sphere to the given point.

public

Checks if this sphere equals the given one.

public

Checks if the this sphere intersects with the given box.

public

Checks if the this sphere intersects with the given plane.

public

Checks if the this sphere intersects with the given one.

public

Checks if this sphere is empty.

public

set(center: Vector3, radius: Number): Sphere

Sets the center and the radius.

public

Computes the bounding sphere of the given box.

public

setFromPoints(points: Vector3[], center: Vector3): Sphere

Sets this sphere from points.

public

translate(offset: Number): Sphere

Translates this sphere.

Public Constructors

public constructor(center: Vector3, radius: Number) source

Constructs a new sphere.

Params:

NameTypeAttributeDescription
center Vector3
  • optional

The center.

radius Number
  • optional

The radius.

Public Members

public center: Vector3 source

The center.

public radius: Number source

The radius.

Public Methods

public clampPoint(p: Vector3, target: Vector3): Vector3 source

Clamps the given point to this sphere.

Params:

NameTypeAttributeDescription
p Vector3

A point.

target Vector3
  • optional

A target vector. If none is provided, a new one will be created.

Return:

Vector3

The clamped point.

public clone(): Sphere source

Clones this sphere.

Return:

Sphere

The cloned sphere.

public containsPoint(p: Vector3): Boolean source

Checks if the given point lies inside this sphere.

Params:

NameTypeAttributeDescription
p Vector3

A point.

Return:

Boolean

Whether this sphere contains the point.

public copy(s: Sphere): Sphere source

Copies the given sphere.

Params:

NameTypeAttributeDescription
s Sphere

A sphere.

Return:

Sphere

This sphere.

public distanceToPoint(p: Vector3): Number source

Calculates the distance from this sphere to the given point.

Params:

NameTypeAttributeDescription
p Vector3

A point.

Return:

Number

The distance.

public equals(s: Sphere): Boolean source

Checks if this sphere equals the given one.

Params:

NameTypeAttributeDescription
s Sphere

A sphere.

Return:

Boolean

Whether the spheres are equal.

public intersectsBox(b: Box3): Boolean source

Checks if the this sphere intersects with the given box.

Params:

NameTypeAttributeDescription
b Box3

A box.

Return:

Boolean

Whether this sphere intersects with the given box.

public intersectsPlane(p: Plane): Boolean source

Checks if the this sphere intersects with the given plane.

Params:

NameTypeAttributeDescription
p Plane

A plane.

Return:

Boolean

Whether this sphere intersects with the given plane.

public intersectsSphere(s: Sphere): Boolean source

Checks if the this sphere intersects with the given one.

Params:

NameTypeAttributeDescription
s Sphere

A sphere.

Return:

Boolean

Whether this sphere intersects with the given one.

public isEmpty(): Boolean source

Checks if this sphere is empty.

Return:

Boolean

Whether this sphere is empty.

public set(center: Vector3, radius: Number): Sphere source

Sets the center and the radius.

Params:

NameTypeAttributeDescription
center Vector3

The center.

radius Number

The radius.

Return:

Sphere

This sphere.

public setFromBox(box: Box3): Sphere source

Computes the bounding sphere of the given box.

Params:

NameTypeAttributeDescription
box Box3

A box.

Return:

Sphere

This pshere.

public setFromPoints(points: Vector3[], center: Vector3): Sphere source

Sets this sphere from points.

Params:

NameTypeAttributeDescription
points Vector3[]

The points.

center Vector3
  • optional

An optional center.

Return:

Sphere

This sphere.

public translate(offset: Number): Sphere source

Translates this sphere.

Params:

NameTypeAttributeDescription
offset Number

An offset.

Return:

Sphere

This sphere.