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

Cartesian : Object
ExtensionExtension

Cartesian point in 3D space
Source: Cartesian.sc
Subclasses: CartesianArray

Description

Defines a point in 3D Cartesian space.

Part of MathLib, a diverse library of mathematical functions.

Class Methods

Cartesian.new(x: 0, y: 0, z: 0)

Defines a new Cartesian point.

Inherited class methods

Instance Methods

Accessing

.x

.x = value

Get or set the x coordinate value.

.y

.y = value

Get or set the y coordinate value.

.z

.z = value

Get or set the z coordinate value.

.set(argX: 0, argY: 0, argZ: 0)

Sets the Cartesian point x, y and z values.

Testing

==(aCartesian)

Answers a Boolean whether the receiver equals the argument.

.hash

Returns a hash value for the receiver.

Math

+(delta)

Addition.

Arguments:

delta

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

-(delta)

Subtraction.

Arguments:

delta

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

*(scale)

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.

/(scale)

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(delta)

Addition by a Cartesian point.

.scale(scale)

Multiplication by a Cartesian point.

.div(scale)

Division by a Cartesian point.

.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.

.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(aCart)

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(quant)

Round the coordinate values to a multiple of quantum.

.trunc(quant)

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 ]

Inherited instance methods

Undocumented instance methods

.asRect

.mod(that)

Authors

Joseph Anderson, 2011.