Cartesian:
Filter:
MathLib/Classes (extension) | Geometry | Libraries > MathLib > Cartesian &c.

Cartesian
ExtensionExtension

Cartesian point in 3D space

Description

Defines a point in 3D Cartesian space.

Part of MathLib, a diverse library of mathematical functions.

Class Methods

.new

Defines a new Cartesian point.

Instance Methods

Accessing

.x

Get or set the x coordinate value.

.y

Get or set the y coordinate value.

.z

Get or set the z coordinate value.

.set

Sets the Cartesian point x, y and z values.

Testing

==

Answers a Boolean whether the receiver equals the argument.

.hash

Returns a hash value for the receiver.

Math

+

Addition.

Arguments:

delta

May be a Number, a Point, an Array or a Cartesian point.

-

Subtraction.

Arguments:

delta

May be a Number, a Point, an Array or a Cartesian point.

*

Multiplication.

Arguments:

scale

May be a Number, a Point, an Array or a Cartesian point.

Returns:

Cartesian.new(this.x * scale.x, this.y * scale.y, this.z * scale.z)

Discussion:

Note that the result of * for a 3D Cartesian point does not match that of Point, where the result is interpreted as the multiplication of complex numbers.

/

Division.

Arguments:

scale

May be a Number, a Point, an Array or a Cartesian point.

Returns:

Cartesian.new(this.x / scale.x, this.y / scale.y, this.z / scale.z)

Discussion:

Note that the result of / for a 3D Cartesian point does not match that of Point, where the result is interpreted as the division of complex numbers.

.translate

Addition by a Cartesian point.

.scale

Multiplication by a Cartesian point.

.div

Division by a Cartesian point.

.rotate

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

Discussion:

Positive values rotate from +X towards +Y

.tilt

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

Discussion:

Positive values rotate from +Y towards +Z

.tumble

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

Discussion:

Positive values rotate from +X towards +Z

.rotateXY

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

Discussion:

A synonym for rotate.

.rotateYZ

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

Discussion:

A synonym for tilt.

.rotateXZ

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.

.abs

Absolute value of the point.

.rho

Return the spherical coordinate radius of the receiver.

.theta

Return the spherical coordinate azimuth angle of the receiver.

.phi

Return the spherical coordinate elevation angle of the receiver.

.angle

Return the spherical coordinate azimuth angle of the receiver.

.angles

Return the spherical coordinate azimuth and elevation angles of the receiver.

Returns:

[ theta, phi]

.dist

Return the distance from the receiver to aCart.

.transpose

Return a Cartesian point whose x and y coordinates are swapped.

Discussion:

Matches the return value for Point: -transpose.

.transposeXY

Return a Cartesian point whose x and y coordinates are swapped.

Discussion:

A synonym for transpose.

.transposeYZ

Return a Cartesian point whose y and z coordinates are swapped.

.transposeXZ

Return a Cartesian point whose x and z coordinates are swapped.

.round

Round the coordinate values to a multiple of quantum.

.trunc

Truncate the coordinate values to a multiple of quantum.

Conversion

.asCartesian

Returns the receiver.

.asPoint

Returns a Point, discarding z.

.asComplex

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

.asPolar

Returns a Polar, discarding z.

.asSpherical

Returns a Spherical.

.asArray

Returns an Array.

Returns:

[ x, y, z ]

Authors

Joseph Anderson, 2011.