Vector4
4D vector value type with native bridge support for interpolation, projection, clamped length, and movement helpers.
Namespace: Lenga\Engine\Core
Key Members
- x, y, z, w: scalar components.
- sqrMagnitude, magnitude, normalized: common length helpers.
- toVector2(), toVector3(): dimensional down-conversion helpers.
- fromVector2(...), fromVector3(...): dimensional up-conversion helpers.
Common Methods
- public static function zero()
- public static function one()
- public function add(Vector4 $other)
- public function subtract(Vector4 $other)
- public function multiply(Vector4 $other)
- public function divide(Vector4 $other)
- public function scale(float $scalar)
- public function normalize()
- public function set(float $x, float $y, float $z, float $w)
- public static function dot(Vector4 $a, Vector4 $b)
- public static function distance(Vector4 $a, Vector4 $b)
- public static function lerp(Vector4 $a, Vector4 $b, float $t)
- public static function lerpUnclamped(Vector4 $a, Vector4 $b, float $t)
- public static function max(Vector4 $a, Vector4 $b)
- public static function min(Vector4 $a, Vector4 $b)
- public static function clampMagnitude(Vector4 $vector, float $maxLength)
- public static function moveTowards(Vector4 $current, Vector4 $target, float $maxDelta)
- public static function project(Vector4 $vector, Vector4 $onNormal)
Use Vector4 when you need four-channel math, homogeneous coordinates, packed data, or cross-conversion with Vector2 and Vector3 without losing the familiar scripting API shape.