Skip to content
FutureBlitz

    Install

    Import std.math.int_vector

    std.math.int_vector

    Vec2i and Vec3i: points and steps on a grid, as Ints, for cells, tiles, and voxels, and as Map keys. Their Operators work component by component, and an Int scales; dividing rounds toward 0, as Ints do, and dividing by 0, or overflow in debug builds, panics where it's called, as it does for an Int.

    std/math/int_vector.fb

    Types

    Vec2i struct

    Public Struct Vec2i Implements Numeric, Hashable, Printable, Defaultable

    A cell or step on a 2D grid.

    std/math/int_vector.fb, line 11

    • Public Field x: Int field #

      Its x component.

    • Public Field y: Int field #

      Its y component.

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

      The number that adding leaves alone: 0.

      Doc from std.core.interfaces.Numeric.Zero.

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

      The number that multiplying leaves alone: 1.

      Doc from std.core.interfaces.Numeric.One.

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

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

      Doc from std.core.interfaces.Defaultable.DefaultValue.

    • Public Method ToVec2(): Vec2 method #

      The components as Floats, rounded to the nearest one a Float holds.

    • Public Method ToString(): String method #

      Its text, as a string interpolation like "{value}" shows it.

      Doc from std.core.interfaces.Printable.ToString.

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

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

    • @PanicsAtCaller Operator +(a: Vec2i, b: Vec2i): Vec2i operator #

      a and b added up.

      Doc from std.core.interfaces.Numeric.Operator+.

    • @PanicsAtCaller Operator -(a: Vec2i, b: Vec2i): Vec2i operator #

      b taken away from a.

      Doc from std.core.interfaces.Numeric.Operator-.

    • @PanicsAtCaller Operator *(a: Vec2i, b: Vec2i): Vec2i operator #

      a and b multiplied together.

      Doc from std.core.interfaces.Numeric.Operator*.

    • @PanicsAtCaller Operator /(a: Vec2i, b: Vec2i): Vec2i operator #

      a divided by b.

      Doc from std.core.interfaces.Numeric.Operator/.

    • @PanicsAtCaller Operator *(a: Vec2i, scale: Int): Vec2i operator #

      a times scale.

    • @PanicsAtCaller Operator *(scale: Int, a: Vec2i): Vec2i operator #

      scale times a.

    • @PanicsAtCaller Operator /(a: Vec2i, scale: Int): Vec2i operator #

      a divided by scale.

    • @PanicsAtCaller Operator -(a: Vec2i): Vec2i operator #

      a negated.

    Vec3i struct

    Public Struct Vec3i Implements Numeric, Hashable, Printable, Defaultable

    A cell or step on a 3D grid.

    std/math/int_vector.fb, line 64

    • Public Field x: Int field #

      Its x component.

    • Public Field y: Int field #

      Its y component.

    • Public Field z: Int field #

      Its z component.

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

      The number that adding leaves alone: 0.

      Doc from std.core.interfaces.Numeric.Zero.

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

      The number that multiplying leaves alone: 1.

      Doc from std.core.interfaces.Numeric.One.

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

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

      Doc from std.core.interfaces.Defaultable.DefaultValue.

    • Public Method ToVec3(): Vec3 method #

      The components as Floats, rounded to the nearest one a Float holds.

    • Public Method ToString(): String method #

      Its text, as a string interpolation like "{value}" shows it.

      Doc from std.core.interfaces.Printable.ToString.

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

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

    • @PanicsAtCaller Operator +(a: Vec3i, b: Vec3i): Vec3i operator #

      a and b added up.

      Doc from std.core.interfaces.Numeric.Operator+.

    • @PanicsAtCaller Operator -(a: Vec3i, b: Vec3i): Vec3i operator #

      b taken away from a.

      Doc from std.core.interfaces.Numeric.Operator-.

    • @PanicsAtCaller Operator *(a: Vec3i, b: Vec3i): Vec3i operator #

      a and b multiplied together.

      Doc from std.core.interfaces.Numeric.Operator*.

    • @PanicsAtCaller Operator /(a: Vec3i, b: Vec3i): Vec3i operator #

      a divided by b.

      Doc from std.core.interfaces.Numeric.Operator/.

    • @PanicsAtCaller Operator *(a: Vec3i, scale: Int): Vec3i operator #

      a times scale.

    • @PanicsAtCaller Operator *(scale: Int, a: Vec3i): Vec3i operator #

      scale times a.

    • @PanicsAtCaller Operator /(a: Vec3i, scale: Int): Vec3i operator #

      a divided by scale.

    • @PanicsAtCaller Operator -(a: Vec3i): Vec3i operator #

      a negated.

    Functions

    Dot function

    @PanicsAtCaller Public Function Dot(a: Vec2i, b: Vec2i): Int

    The sum of the products of the components.

    std/math/int_vector.fb, line 120

    Dot function

    @PanicsAtCaller Public Function Dot(a: Vec3i, b: Vec3i): Int

    The dot product of a and b.

    std/math/int_vector.fb, line 124

    LengthSquared function

    @PanicsAtCaller Public Function LengthSquared(v: Vec2i): Int

    The length times itself, which is a whole number.

    std/math/int_vector.fb, line 128

    LengthSquared function

    @PanicsAtCaller Public Function LengthSquared(v: Vec3i): Int

    The length of v times itself.

    std/math/int_vector.fb, line 132

    ManhattanDistance function

    @PanicsAtCaller Public Function ManhattanDistance(a: Vec2i, b: Vec2i): Int

    How many steps along the axes go from a to b: the taxicab distance.

    std/math/int_vector.fb, line 136

    ManhattanDistance function

    @PanicsAtCaller Public Function ManhattanDistance(a: Vec3i, b: Vec3i): Int

    How many steps along the axes go from a to b: the taxicab distance.

    std/math/int_vector.fb, line 140

    ChebyshevDistance function

    @PanicsAtCaller Public Function ChebyshevDistance(a: Vec2i, b: Vec2i): Int

    How many steps go from a to b where a diagonal is one step too: the chessboard distance.

    std/math/int_vector.fb, line 146

    ChebyshevDistance function

    @PanicsAtCaller Public Function ChebyshevDistance(a: Vec3i, b: Vec3i): Int

    How many steps go from a to b where a diagonal is one step too: the chessboard distance.

    std/math/int_vector.fb, line 150

    Min function

    Public Function Min(a: Vec2i, b: Vec2i): Vec2i

    The smaller of each component.

    std/math/int_vector.fb, line 156

    Min function

    Public Function Min(a: Vec3i, b: Vec3i): Vec3i

    The smaller of each component.

    std/math/int_vector.fb, line 158

    Max function

    Public Function Max(a: Vec2i, b: Vec2i): Vec2i

    The larger of each component.

    std/math/int_vector.fb, line 161

    Max function

    Public Function Max(a: Vec3i, b: Vec3i): Vec3i

    The larger of each component.

    std/math/int_vector.fb, line 163

    Clamp function

    @PanicsAtCaller Public Function Clamp(v: Vec2i, low: Vec2i, high: Vec2i): Vec2i

    Each component kept between low's and high's, as Clamp keeps an Int. A component whose low is above its high panics.

    std/math/int_vector.fb, line 167

    Clamp function

    @PanicsAtCaller Public Function Clamp(v: Vec3i, low: Vec3i, high: Vec3i): Vec3i

    Each component kept between low's and high's, as Clamp keeps an Int. A component whose low is above its high panics.

    std/math/int_vector.fb, line 174

    Abs function

    @PanicsAtCaller Public Function Abs(v: Vec2i): Vec2i

    Each component's Abs.

    std/math/int_vector.fb, line 180

    Abs function

    @PanicsAtCaller Public Function Abs(v: Vec3i): Vec3i

    Each component without its sign.

    std/math/int_vector.fb, line 184

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