GraphMine

util-math / io.github.sof3.graphmine.util.math / Vector3

Vector3

inline class Vector3

A 3-dimensional vector in floating point precision. Intended to store non-aligned positions, e.g. entity positions.

The class is a value class. Values in this class cannot be changed. Therefore, no copy method is present.

Constructors

<init> Vector3(x: Double, y: Double, z: Double)
Constructs a Vector3 by specifying all coordinatesVector3(values: DoubleArray)
A 3-dimensional vector in floating point precision. Intended to store non-aligned positions, e.g. entity positions.

Properties

length val length: Double
Calculates the length (a.k.a. norm or modulus) of this vector.
lengthSquared val lengthSquared: Double
Calculates the squared length of this vector
unit val unit: Vector3
x val x: Double
The x-component value
y val y: Double
The y-component value, which is orthogonal to x
z val z: Double
The z-component value, which is in the direction of x×y

Functions

abs fun abs(): Vector3
ceil fun ceil(): IntVector3
Rounds up this vector to an IntVector3
cross infix fun cross(v: Vector3): Vector3
Calculates the cross product of this and v
distanceSquared fun distanceSquared(that: Vector3): Double
Calculates the squared distance between this and that
distanceTo infix fun distanceTo(that: Vector3): Double
Calculates the distance between this and that.
div operator fun div(scalar: Double): Vector3
Divides the components of this by scalar
dot infix fun dot(v: Vector3): Double
Calculates the dot product of this and v
floor fun floor(): IntVector3
Rounds down this vector to an IntVector3
minus operator fun minus(that: Vector3): Vector3
Calculates this - that
plus operator fun plus(that: Vector3): Vector3
Calculates this + that
round fun round(): IntVector3
Rounds this vector to an IntVector3fun round(dp: Int): Vector3
Rounds this vector to dp decimal places
side fun side(side: Side): Vector3
fun side(side: Side, steps: Double): Vector3
times operator fun times(scalar: Double): Vector3
Multiplies the components of this by scalar
unaryMinus operator fun unaryMinus(): Vector3
unaryPlus operator fun unaryPlus(): Vector3

Companion Object Properties

INF val INF: Vector3
A vector pointing to the infinity in the (+,+,+) octant
INF_NEG val INF_NEG: Vector3
A vector pointing to the infinity in the (-,-,-) octant
UNIT_X val UNIT_X: Vector3
A unit vector in the direction of x (east)
UNIT_X_NEG val UNIT_X_NEG: Vector3
A unit vector in the direction of -x (west)
UNIT_Y val UNIT_Y: Vector3
A unit vector in the direction of y (up)
UNIT_Y_NEG val UNIT_Y_NEG: Vector3
A unit vector in the direction of -y (down)
UNIT_Z val UNIT_Z: Vector3
A unit vector in the direction of z (south)
UNIT_Z_NEG val UNIT_Z_NEG: Vector3
A unit vector in the direction of -z (north)
ZERO val ZERO: Vector3
A zero vector