DWScript provides high-performance types for 3D calculations, optimized for speed and readability.
A 4-component vector (X, Y, Z, W) implemented as a record with overloaded operators.
| Operator | Meaning |
|---|---|
+, - |
Component-wise addition/subtraction. |
* (Vector) |
Dot product (Scalar result). |
^ (Vector) |
Cross product (Vector result). |
*, / (Float) |
Scalar scaling. |
| Function | Description |
|---|---|
Vector(x, y, z, w=0) |
Returns a new TVector. |
VectorNormalize(v) |
Returns unit vector (length 1.0). |
VectorDotProduct(v1, v2) |
Calculates the dot product. |
VectorCrossProduct(v1, v2) |
Calculates the cross product. |
VectorToStr(v) |
Returns formatted string: "[X Y Z W]". |
var v1 := Vector(1, 0, 0);
var v2 := Vector(0, 1, 0);
// Addition
var v3 := v1 + v2;
// Dot product (scalar result)
var dot := v1 * v2;
// Cross product (vector result)
var cross := v1 ^ v2;
PrintLn(VectorToStr(cross)); [0.00 0.00 1.00 0.00]