Skip to content
FutureBlitz

    Install

    Import std.math.geometry

    Sphere

    std.math.geometry

    struct

    Public Struct Sphere Implements Equatable, Printable

    A ball: the points no further from its Center than its Radius.

    Examples

    
    Local ball = Sphere(Vec3(0, 0, 0), 1)
    Expect(ball.Contains(Vec3(0.5, 0, 0)))
    Expect(ball.Raycast(Ray(Vec3(0, 0, 5), Vec3(0, 0, -1))) == 4.0)

    std/math/geometry.fb, line 265

    • Public Field Center: Vec3 field #

      The point in its middle.

    • Public Field Radius: Float field #

      How far its surface is from its Center.

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

      Whether the point is in the sphere or on its surface, by squares in Doubles, which no Float's square overflows.

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

      Whether the two have a point in common, by squares in Doubles.

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

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

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

      How far along the ray it first meets the sphere, worked out in Doubles from where the ray comes nearest the center, as Ray Tracing Gems' chapter 7 has it, so a sphere far off or small, or a short Direction, loses nothing to rounding.

    • Public Method ToString(): String method #

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

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