Vec3

data class Vec3<T : Number, Comparable<T>>(val x: T, val y: T, val z: T, val type: KClass<T>) : Vec<T>

3D vector with coordinates (x, y, z).

Can also be used to specify RGB color values.

Constructors

Link copied to clipboard
constructor(x: T, y: T, z: T, type: KClass<T>)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
infix fun cross(other: Vec3<T>): Vec3<T>

Calculates cross product of this vector and the other vector.

Link copied to clipboard
operator fun div(number: T): Vec3<T>

Divides this vector by the specified number.

Link copied to clipboard
infix fun dot(other: Vec3<T>): T

Calculates dot product of this vector and the other vector.

Link copied to clipboard
fun magnitude(): T

Returns the magnitude of this vector.

Link copied to clipboard
operator fun minus(other: Vec3<T>): Vec3<T>

Subtracts the other vector from this vector.

Link copied to clipboard
fun normalize(): Vec3<T>

Returns a unit vector in the direction of this vector.

Link copied to clipboard
operator fun plus(other: Vec3<T>): Vec3<T>

Adds the other vector to this vector.

Link copied to clipboard
operator fun times(number: T): Vec3<T>

Multiplies this vector by the specified number.

Link copied to clipboard

Returns a Compose Color representation of this Vec3.

Link copied to clipboard

Returns a color int representation of this Vec3.

Link copied to clipboard

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns a 3D double-precision float vector equal to this vector.

Link copied to clipboard

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns a 3D float vector equal to this vector.

Link copied to clipboard

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns a 3D integer vector equal to this vector.

Link copied to clipboard
open override fun toList(): List<T>

Returns a list of coordinates of this vector.

Link copied to clipboard

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns a 3D long integer vector equal to this vector.

Link copied to clipboard

Returns a 4D vector which is a rational form of this 3D vector.

Link copied to clipboard
fun toVec2(): Vec2<T>

Returns a 2D vector with x and y coordinates of this vector.

Link copied to clipboard
fun toVec4(w: T = zero(this.type)): Vec4<T>

Returns a 4D vector with x, y and `z coordinates of this vector and the given w coordinate.

Link copied to clipboard
operator fun unaryMinus(): Vec3<T>

Returns a vector opposite to this vector.

Link copied to clipboard
operator fun unaryPlus(): Vec3<T>

Returns this vector.

Properties

Link copied to clipboard
val b: T

Blue channel of RGB color.

Link copied to clipboard
val g: T

Green channel of RGB color.

Link copied to clipboard
val r: T

Red channel of RGB color.

Link copied to clipboard
val type: KClass<T>

Type of vector coordinates.

Link copied to clipboard
val x: T

X coordinate of this vector.

Link copied to clipboard
val y: T

Y coordinate of this vector.

Link copied to clipboard
val z: T

Z coordinate of this vector.