Skip to main content
Module

x/gmath/mod.ts>Vector4

🎮 A wasm accelerated game and graphics maths library for deno
Latest
class Vector4
implements Point4
Re-export
import { Vector4 } from "https://deno.land/x/gmath@0.1.12/mod.ts";

Constructors

new
Vector4()
new
Vector4(x: number)
new
Vector4(
x: number,
y: number,
z: number,
w: number,
)
new
Vector4(source: Float32Array)
new
Vector4(
x?: number | Float32Array,
y?: number,
z?: number,
w?: number,
)

Properties

w: number
x: number
y: number
z: number
[0]: number
[1]: number
[2]: number
[3]: number

Methods

add(other: number | Vector4): Vector4

Adds this Vector4 to the specified Vector4 or scalar

clamp(length: number): Vector4

Creates a new Vector2 with the same values

div(other: number | Vector4): Vector4

Divides this Vector4 with the specified Vector4 or scalar

dot(other: Vector4): number

Calculates the dot product of this Vector4

eq(other: Vector4): boolean

Checks equality between two Vector4

isFinite(): boolean

Checks if the Vector4 is finite

lerp(other: Vector4, alpha: number): Vector4

Linearly interpolates between this and the specified Vector4

mag(): number

The magnitude of this Vector4

mag2(): number

The squared magnitude of this Vector4

Calculates the midpoint between two Vector4

mul(other: number | Vector4): Vector4

Multiplies this Vector4 with the specified Vector4 or scalar

Negates the values of this Vector4

Returns a new Vector2 with the same direction, but with a magnitude of 1

Sets the x, y, z and w of this Vector4 to the specified Vector4 x, y, z and w values

sub(other: number | Vector4): Vector4

Subtracts this Vector4 from the specified Vector4 or scalar

toArray():
[
number,
number,
number,
number,
]

Converts the Vector4 to a tuple of numbers

toFloat32Array(): Float32Array

Converts the Vector to a Float32Array

toString(): string

Converts the Vector4 to a string

Truncates this Vector4 to a Vector3 dropping the w value

truncN(n:
| 0
| 1
| 2
| 3
): Vector3

Truncates this Vector4 to a Vector3 dropping the nth value

Static Methods

A Vector4 with all values set to Number.NEGATIVE_INFINITY

A Vector4 with all values set to 1

A Vector4 with all values set to Number.POSITIVE_INFINITY

A Vector4 with all values set to 0