Spherical:
Filter:
Classes (extension) |

# Spherical : Number : Magnitude : ObjectExtension

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

## Instance Methods

### .rho = value

Get or set the rho coordinate value.

### .theta = value

Get or set the theta coordinate value.

### .phi = value

Get or set the phi coordinate value.

### .hash

Returns a hash value for the receiver.

### /(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.

[ theta, phi ]

[ theta, phi ]

### .asComplex

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

### .asCartesian

Convert to Cartesian.

## Authors

Joseph Anderson, 2011.