GraphMine

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

IntVector3

inline class IntVector3

A 3-dimensional vector in integers. Intended to store aligned positions e.g. block positions.

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

Constructors

<init> IntVector3(x: Int, y: Int, z: Int)
Consrtucts a Vector3 by specifying all coordinatesIntVector3(values: IntArray)
A 3-dimensional vector in integers. Intended to store aligned positions e.g. block positions.

Properties

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

Functions

abs fun abs(): IntVector3
cross infix fun cross(v: IntVector3): IntVector3
Calculates the cross product of this and v
distanceSquared fun distanceSquared(that: IntVector3): Int
Calculates the squared distance between this and that
distanceTo infix fun distanceTo(that: IntVector3): Double
Calculates the distance between this and that.
dot infix fun dot(v: IntVector3): Int
Calculates the dot product of this and v
eachSide fun eachSide(fn: (IntVector3) -> Unit): Unit
minus operator fun minus(that: IntVector3): IntVector3
Calculates this - that
plus operator fun plus(that: IntVector3): IntVector3
Calculates this + that
rangeTo operator fun rangeTo(that: IntVector3): IntVector3Range
Returns the minimum IntVector3Range that inclusively contains both this and that
side fun side(side: Side): IntVector3
fun side(side: Side, steps: Int): IntVector3
times operator fun times(scalar: Int): IntVector3
Multiplies the components of this by scalar
toDouble fun toDouble(): Vector3
Converts to a Vector3 with approximately equivalent positions
unaryMinus operator fun unaryMinus(): IntVector3
unaryPlus operator fun unaryPlus(): IntVector3

Companion Object Properties

UNIT_X val UNIT_X: IntVector3
A unit vector in the direction of x (east)
UNIT_X_NEG val UNIT_X_NEG: IntVector3
A unit vector in the direction of -x (west)
UNIT_Y val UNIT_Y: IntVector3
A unit vector in the direction of y (up)
UNIT_Y_NEG val UNIT_Y_NEG: IntVector3
A unit vector in the direction of -y (up)
UNIT_Z val UNIT_Z: IntVector3
A unit vector in the direction of z (south)
UNIT_Z_NEG val UNIT_Z_NEG: IntVector3
A unit vector in the direction of -z (north)
ZERO val ZERO: IntVector3
A zero vector