Skip to content
FutureBlitz

    Install

    Import std.math.geometry

    AABB

    std.math.geometry

    struct

    Public Struct AABB Implements Equatable, Printable

    An axis-aligned box in 3D, from its corner with the smallest x, y, and z to the one with the largest.

    Examples

    
    Local box = AABB(Vec3(-1, -1, -1), Vec3(1, 1, 1))
    Local ray = Ray(Vec3(0, 0, 5), Vec3(0, 0, -1))
    Expect(box.Raycast(ray) == 4.0)
    Expect(ray.At(4) == Vec3(0, 0, 1))
    Expect(box.Contains(Vec3(0.5, 0, 0)) && !box.Contains(Vec3(2, 0, 0)))

    std/math/geometry.fb, line 133

    • Public Field Min: Vec3 field #

      Its corner with the smallest x, y, and z.

    • Public Field Max: Vec3 field #

      Its corner with the largest x, y, and z.

    • Public Static Method FromCenter(center: Vec3, size: Vec3): AABB static method #

      The box of the size, with its center at the point.

    • @PanicsAtCaller Public Static Method FromPoints(points: Vec3[]): AABB static method #

      The smallest box that holds every point. No points panics.

    • Public Property Center: Vec3 property #

      The point in its middle.

    • Public Property Size: Vec3 property #

      How wide, high, and deep it is.

    • Public Property Extents: Vec3 property #

      Half the size: how far each face is from the center.

    • Public Method Contains(point: Vec3): Bool method #

      Whether the point is in the box or on its surface.

    • Public Method Contains(other: AABB): Bool method #

      Whether the other box is all in this one.

    • Public Method Intersects(other: AABB): Bool method #

      Whether the two have a point in common, a face's included.

    • Public Method Intersects(sphere: Sphere): Bool method #

      Whether the sphere and the box have a point in common.

    • Public Method ClosestPoint(point: Vec3): Vec3 method #

      The point in the box nearest the one given: that point itself when it's inside.

    • Public Method Raycast(ray: Ray): Float? method #

      How far along the ray it first meets the box, by its slabs, one axis at a time.

    • Public Method Union(other: AABB): AABB method #

      The smallest box that holds both.

    • Public Method Union(point: Vec3): AABB method #

      The smallest box that holds this one and the point.

    • Public Method Grow(amount: Float): AABB method #

      The box with each face moved out by amount, or in by a negative one. Shrunk past nothing, an axis is 0 long, at the center.

    • Public Method Transform(m: Mat4): AABB method #

      The smallest box that holds this one transformed by the matrix, as an object's box is moved into the world.

    • Public Method ToString(): String method #

      Its parts, as "AABB((0, 0, 0), (1, 1, 1))".

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