Vec3

open class Vec3(x: Double, y: Double, var z: Double) : Vec2

Three-component vector with X, Y and Z coordinates.

Constructors

Link copied to clipboard
constructor(x: Double, y: Double, z: Double)
constructor()

Constructs a three-component vector with X, Y and Z all 0.

constructor(vector: Vec3)

Constructs a three-component vector with the X, Y and Z of a specified vector.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Computes the magnitude of this vector.

Link copied to clipboard
open override val magnitudeSquared: Double

Computes the squared magnitude of this vector. This is equivalent to squaring the result of magnitude but is potentially much more efficient.

Link copied to clipboard
var x: Double

The vector's X component.

Link copied to clipboard
var y: Double

The vector's Y component.

Link copied to clipboard
var z: Double

The vector's Z component.

Functions

Link copied to clipboard
fun add(vector: Vec2): Vec2
fun add(vector: Vec3): Vec3

Adds a specified vector to this vector.

Link copied to clipboard
fun copy(vector: Vec2): Vec2

Sets this vector to the X and Y of a specified vector.

fun copy(vector: Vec3): Vec3

Sets this vector to the X, Y and Z of a specified vector.

Link copied to clipboard
fun cross(vector: Vec3): Vec3

Computes the cross product of this vector and a specified vector, modifying this vector.

fun cross(a: Vec3, b: Vec3): Vec3

Computes the cross product of two vectors, setting this vector to the result.

Link copied to clipboard
fun distanceTo(vector: Vec2): Double
fun distanceTo(vector: Vec3): Double

Computes the distance from this vector to another vector.

Link copied to clipboard

Computes the squared distance from this vector to a specified vector. This is equivalent to squaring the result of distanceTo but is potentially much more efficient.

Link copied to clipboard
open operator override fun div(divisor: Double): Vec3

Creates new vector containing this vector divided by a scalar.

Link copied to clipboard
open operator override fun divAssign(divisor: Double)

Divides this vector by a scalar.

Link copied to clipboard
open override fun divide(divisor: Double): Vec3

Divides this vector by a scalar.

Link copied to clipboard
fun dot(vector: Vec2): Double
fun dot(vector: Vec3): Double

Computes the scalar dot product of this vector and a specified vector.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
operator fun minus(vector: Vec2): Vec2
operator fun minus(vector: Vec3): Vec3

Creates new vector containing difference of this and specified vectors.

Link copied to clipboard
operator fun minusAssign(vector: Vec2)
operator fun minusAssign(vector: Vec3)

Subtracts a specified vector from this vector.

Link copied to clipboard
fun mix(vector: Vec2, weight: Double): Vec2
fun mix(vector: Vec3, weight: Double): Vec3

Mixes (interpolates) a specified vector with this vector, modifying this vector.

Link copied to clipboard
open override fun multiply(scalar: Double): Vec3

Multiplies this vector by a scalar.

Link copied to clipboard

Multiplies this vector by a 3x3 matrix. The multiplication is performed with an implicit Z component of 1. The resultant Z component of the product is then divided through the X and Y components.

Multiplies this vector by a 4x4 matrix. The multiplication is performed with an implicit W component of 1. The resultant W component of the product is then divided through the X, Y, and Z components.

Link copied to clipboard
open override fun negate(): Vec3

Negates the components of this vector.

Link copied to clipboard
open override fun normalize(): Vec3

Normalizes this vector to a unit vector.

Link copied to clipboard
operator fun plus(vector: Vec2): Vec2
operator fun plus(vector: Vec3): Vec3

Creates new vector containing sum of this and specified vectors.

Link copied to clipboard
operator fun plusAssign(vector: Vec2)
operator fun plusAssign(vector: Vec3)

Adds a specified vector to this vector.

Link copied to clipboard
fun set(x: Double, y: Double): Vec2

Sets this vector to the specified X and Y.

fun set(x: Double, y: Double, z: Double): Vec3

Sets this vector to the specified X, Y and Z.

Link copied to clipboard
fun subtract(vector: Vec2): Vec2
fun subtract(vector: Vec3): Vec3

Subtracts a specified vector from this vector.

Link copied to clipboard
fun swap(vector: Vec2): Vec2
fun swap(vector: Vec3): Vec3

Swaps this vector with the specified vector. This vector's components are set to the values of the specified vector's components, and the specified vector's components are set to the values of this vector's components.

Link copied to clipboard
open operator override fun times(scalar: Double): Vec3

Creates new vector containing this vector multiplied by a scalar.

Link copied to clipboard
open operator override fun timesAssign(scalar: Double)

Multiplies this vector by a scalar.

Link copied to clipboard
open override fun toArray(result: FloatArray, offset: Int): FloatArray

Copies this vector's components to the specified single precision array. The result is compatible with GLSL uniform vectors, and can be passed to the function glUniform3fv.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open operator override fun unaryMinus(): Vec3

Creates new vector which has components with opposite sign to the vector.