Class Point3f

extends Object
A 3D point with coordinates represented as floats.
Points are immutable.

Class summary


constructor x/num y/num z/num
Creates a point from x, y, and z.

Constructors

Creates a point from x, y, and z.

Statics

deserialize bytes/any -> Point3f
Deserializes bytes into a point instance.
The serialization format is unspecified, but bytes generated by to-byte-array can be deserialized.

Methods

Returns a copy of this instance with absolute coordinates (that is (|x|, |y|, |z|)).

Computes the distance from (0, 0, 0) to this instance.

Returns a copy of this instance with negated coordinates (that is (-x, -y, -z)).

Subtracts this instance from the other and returns the result (that is (x - other.x, y - other.y, z - other.z)).

operator * other/any -> Point3f
Multiplies this instance with the other and returns the result.
The other can be a scalar or another point.
If the other is a point, then multiplication is done per coordinate (that is (x * other.x, y * other.y, z * other.z)).
If the other is a scalar, then each coordinate is multiplied (that is (x * other, y * other, z * other)).

operator / other/any -> Point3f
Divides this instance with the other and returns the result.
The other can be a point or a scalar.
If the other is a point, then the division is done per coordinate (that is (x / other.x, y / other.y, z / other.z)).
If the other is a scalar, then each coordinate is divided by the scalar (that is (x / other, y / other, z / other)).

Adds this instance to the other and returns the result (that is (x + other.x, y + other.y, z + other.z)).

operator == other/any -> bool
Whether this object is equal to the other.
By default, identical is used for equality.
Inheritance
Classes overwrite this operator to get an equality specific to their needs. Equality operators often compare the type and field contents. For example:

class Pin:
  number/int

  constructor .number:

  operator == other:
    if other is not Pin: return false
    return number == other.number
A class doesn't have to follow the above format, but it must keep the operator in sync with any hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).

Converts this instance to a byte array which can be deserialized with Point3f.deserialize.
The serialization format is not stable.

Fields

The x-coordinate of the point.

The y-coordinate of the point.

The z-coordinate of the point.