Vector3 class

Represents 3D points and vectors.

Use this class to pass positions and directions to item transforms and perform vector operations.

Note: By default, DX engine uses Z as "up".

Constructors

constructor(self, x: float, y: float, z: float)

Methods

__add__(self, other: Vector3) -> Vector3

Adds this vector and other by their corresponding components.

angle(self, other: Vector3) -> float

Returns the angle in radians from this vector to other.

cross(self, other: Vector3) -> Vector3

Calculates the cross product of this vector and other

dist(self, other: Vector3) -> float

Returns the distance between this vector and other.

static distance2(a: Vector3, b: Vector3) -> float

Returns the squared distance between vector a and vector b

__truediv__(self, d: float) -> Vector3

Divides all components of this vector by divisor d.

dot(self, other: Vector3) -> float

Calculates the dot product of this vector and other.

__eq__(self, v: Vector3) -> bool

Returns true if this vector equals v.

limit_length(self, l: float) -> Vector3

Returns a copy of this vector with limited length l.

max(self, other: Vector3) -> Vector3

Returns a new vector made from the largest components of this vector and other

min(self, other: Vector3) -> Vector3

Returns a new vector made from the smallest components of this vector and other

__mul__(self, m: float) -> Vector3

Multiplies each component of this by a number m.

project(self, other: Vector3) -> Vector3

Projects this vector onto other.

project_on_plane(self, normal: Vector3) -> Vector3

Projects this vector onto a plane defined by a normal that is orthogonal to it.

__sub__(self, other: Vector3) -> Vector3

Subtracts each component of other from this vector.

to_array(self) -> list[float]

Properties

readonly length float

Returns the length of this vector.

readonly normalized Vector3

Returns a copy of this vector with length 1.

static readonly one Vector3

Shorthand for writing new Vector3(1,1,1).

readonly sqr_length float

Returns the squared length of this vector.

readonly x float

X component of this vector.

readonly y float

Y component of this vector.

readonly z float

Z component of this vector.

static readonly zero Vector3

Shorthand for writing new Vector3(0,0,0).