Skip to content
FutureBlitz

    Install

    Import std.math.vector

    Vec3

    std.math.vector

    struct

    Public Struct Vec3 Implements Numeric, Hashable, Printable, Defaultable

    A point or direction in 3D.

    Examples

    Local right = Vec3(1, 0, 0)
    Local up = Vec3(0, 1, 0)
    Expect(Dot(right, up) == 0.0)
    Expect(Cross(right, up) == Vec3(0, 0, 1))
    Expect(Length(Vec3(3, 4, 0)) == 5.0)
    Expect(Normalize(Vec3(0, 0, 9)) == Vec3(0, 0, 1))
    Expect(Lerp(right, up, 0.5) == Vec3(0.5, 0.5, 0))
    Expect(right * 2 + up == Vec3(2, 1, 0))

    std/math/vector.fb, line 109

    • Public Field x: Float field #

      Its x component.

    • Public Field y: Float field #

      Its y component.

    • Public Field z: Float field #

      Its z component.

    • Public Static Method Zero(): Vec3 static method #

      The zero vector, (0, 0, 0).

    • Public Static Method One(): Vec3 static method #

      The vector (1, 1, 1), which multiplying leaves alone.

    • Public Static Method DefaultValue(): Vec3 static method #

      The zero vector, (0, 0, 0).

    • Public Static Property Up: Vec3 property #

      Up: +Y.

    • Public Static Property Down: Vec3 property #

      Down: -Y.

    • Public Static Property Right: Vec3 property #

      Right: +X.

    • Public Static Property Left: Vec3 property #

      Left: -X.

    • Public Static Property Forward: Vec3 property #

      -Z, where a camera with no rotation looks.

    • Public Static Property Back: Vec3 property #

      Back: +Z, toward the camera.

    • Public Property xy: Vec2 property #

      Its x and y, as a Vec2.

    • @PanicsAtCaller Public Method ToVec3i(): Vec3i method #

      The components as Ints, toward 0, as As converts them: one outside an Int's range panics.

    • Public Method ToString(): String method #

      Its components, as "(1, 2, 3)".

    • @PanicsAtCaller Operator [](index: Int): Float operator #

      The component at the index: x at 0, y at 1, and z at 2. Any other index panics.

    • Operator +(a: Vec3, b: Vec3): Vec3 operator #

      a plus b, component by component.

    • Operator -(a: Vec3, b: Vec3): Vec3 operator #

      a minus b, component by component.

    • Operator *(a: Vec3, b: Vec3): Vec3 operator #

      a times b, component by component.

    • Operator /(a: Vec3, b: Vec3): Vec3 operator #

      a divided by b, component by component.

    • Operator *(a: Vec3, scale: Float): Vec3 operator #

      a times scale.

    • Operator *(scale: Float, a: Vec3): Vec3 operator #

      scale times a.

    • Operator /(a: Vec3, scale: Float): Vec3 operator #

      a divided by scale.

    • Operator -(a: Vec3): Vec3 operator #

      a negated.

    Report an issue with this page or with FutureBlitz on GitHub.