vector4
vector4
The vector4 class represents 4D floating point coordinates (X, Y, Z, W). Supports vector addition, subtraction, scalar multiplication, normalization, and dot products.
Overview
Properties (4)
| Property | Type | Summary |
|---|---|---|
w
|
number
|
The W component. |
x
|
number
|
The X component. |
y
|
number
|
The Y component. |
z
|
number
|
The Z component. |
Methods (4)
| Method Signature | Returns | Summary |
|---|---|---|
vector4:dot(other)
|
number
|
Calculates the dot product with another 4D vector. |
vector4:length()
|
number
|
Calculates the length of the 4D vector. |
vector4.new(x, y, z, w)
|
vector4
|
Constructs a new 4D vector. |
vector4:normalized()
|
vector4
|
Returns a normalized unit vector. |
Detailed Reference
vector4.wnumberThe W coordinate component.
Reads or writes the W coordinate component.
vector4.xnumberThe X coordinate component.
Reads or writes the X coordinate component.
vector4.ynumberThe Y coordinate component.
Reads or writes the Y coordinate component.
vector4.znumberThe Z coordinate component.
Reads or writes the Z coordinate component.
vector4:dot(other)| Parameter | Type | Default | Description |
|---|---|---|---|
other | vector4 | The other 4D vector. |
numberDot product value.
Computes x1 x2 + y1 y2 + z1 z2 + w1 w2.
vector4:length()numberEuclidean magnitude.
Calculates sqrt(x^2 + y^2 + z^2 + w^2).
vector4.new(x, y, z, w)| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | The X coordinate. | |
y | number | The Y coordinate. | |
z | number | The Z coordinate. | |
w | number | The W coordinate. |
vector4Newly constructed 4D vector.
Creates a 4D vector with four components.
vector4:normalized()vector4Unit vector with length 1.0.
Scales the 4D vector to length 1.0.