Vector

class Vector(val x: Double, val y: Double, val z: Double)

A three-dimensional vector used for directions, normals, and light calculations.

Unlike Point, a Vector represents a direction and magnitude rather than a position in space. The subtraction Point - Point yields a Vector, and Point + Vector yields a Point.

Parameters

x

X component of the vector.

y

Y component of the vector.

z

Z component of the vector.

Constructors

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

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val x: Double
Link copied to clipboard
val y: Double
Link copied to clipboard
val z: Double

Functions

Link copied to clipboard
infix fun cross(other: Vector): Vector

Returns the cross product of this vector and other.

Link copied to clipboard
infix fun dot(other: Vector): Double

Returns the dot product of this vector and other.

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

Returns the length (magnitude) of this vector: sqrt(x^2 + y^2 + z^2).

Link copied to clipboard
operator fun minus(other: Vector): Vector

Returns the component-wise difference of this vector and other.

Link copied to clipboard

Returns a unit vector in the same direction. Throws if magnitude is zero.

Link copied to clipboard
operator fun plus(other: Vector): Vector

Returns the component-wise sum of this vector and other.

Link copied to clipboard
operator fun times(scalar: Double): Vector

Returns this vector scaled by scalar.

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

Returns this vector with all components negated.