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

Spherical

A spherical coordinate system.

For details see: https://en.wikipedia.org/wiki/Spherical_coordinate_system

The poles (phi) are at the positive and negative Y-axis. The equator starts at positive Z.

Constructor Summary

Public Constructor
public

constructor(radius: Number, phi: Number, theta: Number)

Constructs a new spherical system.

Member Summary

Public Members
public

The polar angle, up and down towards the top and bottom pole.

public

The radius of the sphere.

public

The angle around the equator of the sphere.

Method Summary

Public Methods
public

Clones this spherical system.

public

Copies the values of the given spherical system.

public

Restricts phi to [1e-6, PI - 1e-6].

public

set(radius: Number, phi: Number, theta: Number): Spherical

Sets the values of this spherical system.

public

Sets the values of this spherical system based on cartesian coordinates.

public

Sets the values of this spherical system based on a vector.

Public Constructors

public constructor(radius: Number, phi: Number, theta: Number) source

Constructs a new spherical system.

Params:

NameTypeAttributeDescription
radius Number
  • optional
  • default: 1

The radius of the sphere.

phi Number
  • optional
  • default: 0

The polar angle phi.

theta Number
  • optional
  • default: 0

The equator angle theta.

Public Members

public phi: Number source

The polar angle, up and down towards the top and bottom pole.

public radius: Number source

The radius of the sphere.

public theta: Number source

The angle around the equator of the sphere.

Public Methods

public clone(): Spherical source

Clones this spherical system.

Return:

Spherical

The cloned spherical system.

public copy(s: Spherical): Spherical source

Copies the values of the given spherical system.

Params:

NameTypeAttributeDescription
s Spherical

A spherical system.

Return:

Spherical

This spherical system.

public makeSafe(): Spherical source

Restricts phi to [1e-6, PI - 1e-6].

Return:

Spherical

This spherical system.

public set(radius: Number, phi: Number, theta: Number): Spherical source

Sets the values of this spherical system.

Params:

NameTypeAttributeDescription
radius Number

The radius.

phi Number

Phi.

theta Number

Theta.

Return:

Spherical

This spherical system.

public setFromCartesianCoords(x: Number, y: Number, z: Number): Spherical source

Sets the values of this spherical system based on cartesian coordinates.

Params:

NameTypeAttributeDescription
x Number

The X coordinate.

y Number

The Y coordinate.

z Number

The Z coordinate.

Return:

Spherical

This spherical system.

public setFromVector3(v: Vector3): Spherical source

Sets the values of this spherical system based on a vector.

The radius is set to the vector's length while phi and theta are set from its direction.

Params:

NameTypeAttributeDescription
v Vector3

The vector.

Return:

Spherical

This spherical system.