struct
Eagle::AABB
- Eagle::AABB
- Struct
- Value
- Object
Overview
An axis-aligned 3D box, given by its #min and #max corners.
Eagle uses it for mesh bounds, picking and culling. MeshInstance3D#global_bounds
returns one, and Ray#intersect_aabb tests against it.
box = AABB.from_center(v3(0, 1, 0), v3(1, 1, 1))
box.contains?(v3(0.5, 1.5, 0)) # => true
ray = Ray.new(v3(0, 1, 10), Vec3::FORWARD)
if dist = ray.intersect_aabb(box)
hit_point = ray.at(dist) # => (0, 1, 1)
end
Defined in:
eagle/math/rect.crConstructors
-
.from_center(center : Vec3, half : Vec3) : AABB
Creates a box from its center and half-extents.
-
.from_points(points : Enumerable(Vec3)) : AABB
The smallest box containing all points.
-
.new(min : Vec3, max : Vec3)
Creates a box from its min and max corners.
Instance Method Summary
-
#center : Vec3
The center point.
-
#contains?(p : Vec3) : Bool
True when the point is inside or on the surface.
-
#half : Vec3
Half the extent: the distance from the center to each face.
-
#intersects?(o : AABB) : Bool
True when the boxes overlap or touch.
-
#max : Vec3
Corner with the largest coordinates.
-
#max=(max : Vec3)
Corner with the largest coordinates.
-
#min : Vec3
Corner with the smallest coordinates.
-
#min=(min : Vec3)
Corner with the smallest coordinates.
-
#size : Vec3
The full extent along each axis.
-
#transformed(m : Mat4) : AABB
The box that bounds this box after transforming it by m.
-
#union(o : AABB) : AABB
The smallest box containing both.
Constructor Detail
Creates a box from its center and half-extents.
Instance Method Detail
The box that bounds this box after transforming it by m. It can be larger than the original when m rotates.