Import std.math.geometry
std.math.geometry
The shapes for finding what's where: Rect in 2D, and AABB, Sphere, Ray, Plane, and Frustum in 3D, with Contains, Intersects, and Raycast. A shape holds the points on its edges. A Raycast gives how far along the ray it first meets the shape, in lengths of the ray's Direction, so a Direction of length 1 makes it a distance; 0 for a ray that starts inside, and Null for one that misses.
std/math/geometry.fb
Types
Rect
struct
Public Struct Rect Implements Equatable, Printable
A rectangle in 2D, from its corner with the smallest X and Y, of a Width and Height that aren't negative.
-
Its left edge, the smallest X it has.
-
Its top edge, the smallest Y it has.
-
How wide it is, which isn't negative.
-
How high it is, which isn't negative.
-
The rectangle from one corner to the other, whichever way around they are.
-
The rectangle of the
size, with its center at the point. -
The corner with the smallest X and Y.
-
The corner with the largest X and Y.
-
The point in its middle.
-
Its Width and Height, as a Vec2.
-
Its Width times its Height.
-
Whether the
pointis in the rectangle or on its edge. -
Whether the
otherrectangle is all in this one. -
Whether the two have a point in common, an edge's included.
-
The rectangle where the two overlap, or Null where they don't meet.
-
The smallest rectangle that holds both.
-
The rectangle with each edge moved out by
amount, or in by a negative one. Shrunk past nothing, a side is 0 long, at the center. -
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
AABB
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.
std/math/geometry.fb, line 105
-
Its corner with the smallest x, y, and z.
-
Its corner with the largest x, y, and z.
-
The box of the
size, with its center at the point. -
The smallest box that holds every point. No points panics.
-
The point in its middle.
-
How wide, high, and deep it is.
-
Half the size: how far each face is from the center.
-
Whether the
pointis in the box or on its surface. -
Whether the
otherbox is all in this one. -
Whether the two have a point in common, a face's included.
-
Whether the
sphereand the box have a point in common. -
The
pointin the box nearest the one given: thatpointitself when it's inside. -
How far along the
rayit first meets the box, by its slabs, one axis at a time. -
The smallest box that holds both.
-
The smallest box that holds this one and the
point. -
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. -
The smallest box that holds this one transformed by the matrix, as an object's box is moved into the world.
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Sphere
struct
Public Struct Sphere Implements Equatable, Printable
A ball: the points no further from its Center than its Radius.
std/math/geometry.fb, line 226
-
The point in its middle.
-
How far its surface is from its Center.
-
Whether the
pointis in the sphere or on its surface, by squares in Doubles, which no Float's square overflows. -
Whether the two have a point in common, by squares in Doubles.
-
Whether the
boxand the sphere have a point in common. -
How far along the
rayit first meets the sphere, worked out in Doubles from where theraycomes 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. -
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Ray
struct
Public Struct Ray Implements Equatable, Printable
A half-line, from its Origin along its Direction.
std/math/geometry.fb, line 288
-
Where it starts.
-
Which way it goes, and how far each length of it along the ray is.
-
The point so far along the ray, in lengths of its Direction.
-
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Plane
struct
Public Struct Plane Implements Equatable, Printable
A flat surface without end, of the points p where Dot(Normal, p) is Distance, with a Normal of length 1. The side the Normal points to is in front.
std/math/geometry.fb, line 302
-
Which way it faces, of length 1.
-
Its distance from the origin along its Normal: Dot(Normal, p) for each point p on it.
-
@PanicsAtCaller Public Static Method FromPointNormal(point: Vec3, normal: Vec3): Planestatic method #The plane through the
point, facing the way thenormaldoes. A zeronormalpanics. -
The plane through the three points, facing the side they go counterclockwise around. Three on a line panic.
-
How far the
pointis in front of the plane, negative behind it. -
The
pointon the plane nearest the one given. -
How far along the
rayit meets the plane, from either side, 0 for a ray that starts on it, whichever way it goes. A ray along it misses. -
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Frustum
struct
Public Struct Frustum Implements Equatable, Printable
What a camera sees: the six planes of its projection, each facing in.
std/math/geometry.fb, line 346
-
Its left plane, facing in.
-
Its right plane, facing in.
-
Its bottom plane, facing in.
-
Its top plane, facing in.
-
Its near plane, facing in.
-
Its far plane, facing in.
-
The frustum of a projection times a view matrix, as Mat4.Perspective and LookAt make them, with depth from 0 to 1, in the space the view matrix takes from: the world's, for a camera.
-
Whether the
pointis inside, or on a plane. -
Whether the
sphereis inside, or partly: False only when it's all behind a plane. -
Whether the
boxis inside, or partly: False only when it's all behind a plane, so a box just past a corner of the frustum can be True, as culling allows. -
Its text, as a string interpolation like "{value}" shows it.
Doc from
std.core.interfaces.Printable.ToString.
Report an issue with this page or with FutureBlitz on GitHub.