Spherical:
Filter:
Classes (extension) | Math | Libraries > MathLib > Cartesian &c.

Spherical : Number : Magnitude : Object
ExtensionExtension

Spherical coordinates
Source: Spherical.sc

Description

Represents spherical coordinates.

Part of MathLib, a diverse library of mathematical functions.

Class Methods

Spherical.new(rho, theta, phi)

Create a new spherical coordinate with the given radius, rho, and angles in radians, theta and phi.

Arguments:

rho

radius

theta

azimuth angle

phi

elevation angle

Inherited class methods

Instance Methods

Accessing

.rho

.rho = value

Get or set the rho coordinate value.

.theta

.theta = value

Get or set the theta coordinate value.

.phi

.phi = value

Get or set the phi coordinate value.

Testing

==(aSpherical)

Answers a Boolean whether the receiver equals the argument.

.hash

Returns a hash value for the receiver.

Math

+(aValue)

-(aValue)

*(aValue)

/(aValue)

The math operations of addition, subtraction, multiplication and division are accomplished by first converting to cartesian coordinates, then answering to spherical coordinates.

.scale(scale)

Scale the radius by some value.

.rotate(angle)

Rotation about the origin in the XY plane by the angle given in radians.

Discussion:

Positive values rotate from +X towards +Y

.tilt(angle)

Rotation about the origin in the YZ plane by the angle given in radians.

Discussion:

Positive values rotate from +Y towards +Z

.tumble(angle)

Rotation about the origin in the XZ plane by the angle given in radians.

Discussion:

Positive values rotate from +X towards +Z

.rotateXY(angle)

Rotation about the origin in the XY plane by the angle given in radians.

Discussion:

A synonym for rotate.

.rotateYZ(angle)

Rotation about the origin in the YZ plane by the angle given in radians.

Discussion:

A synonym for tilt.

.rotateXZ(angle)

Rotation about the origin in the XZ plane by the angle given in radians.

Discussion:

A synonym for tumble.

.mirrorX

Mirror x, reflecting across the YZ plane.

.mirrorY

Mirror y, reflecting across the XZ plane.

.mirrorZ

Mirror z, reflecting across the XY plane.

.mirrorO

Mirror across the origin.

.neg

Rotate theta by pi and negate phi.

Discussion:

This operation is equivalent to negating rho, and is a synonym for mirrorO.

Conversion

.magnitude

Answer the radius.

.angle

Answer the azimuth angle, theta, in radians.

.phase

Answer the azimuth angle, theta, in radians.

.angles

Answer the azimuth and elevation angles, theta and phi, in radians.

Returns:

[ theta, phi ]

.phases

Answer the azimuth and elevation angles, theta and phi, in radians.

Returns:

[ theta, phi ]

.x

Answer the cartesian coordinate x of the receiver.

.y

Answer the cartesian coordinate y of the receiver.

.z

Answer the cartesian coordinate z of the receiver.

.real

Answer the cartesian coordinate x of the receiver.

.imag

Answer the cartesian coordinate y of the receiver.

.asSpherical

Returns the receiver.

.asPolar

Convert to Polar, discarding z.

.asComplex

Answers a Complex with x as the real part and y as the imaginary part, discarding z.

.asPoint

Convert to Point, discarding z.

.asCartesian

Convert to Cartesian.

Inherited instance methods

Undocumented instance methods

.performBinaryOpOnUGen(aSelector, aUGen)

Authors

Joseph Anderson, 2011.