package eu.jonahbauer.raytracing.math;

import org.jetbrains.annotations.NotNull;

public record BoundingBox(@NotNull Vec3 min, @NotNull Vec3 max) {
    public BoundingBox {
        var a = min;
        var b = max;
        min = Vec3.min(a, b);
        max = Vec3.max(a, b);
    }

    public @NotNull Vec3 center() {
        return Vec3.average(min, max, 2);
    }

    public @NotNull BoundingBox expand(@NotNull BoundingBox box) {
        return new BoundingBox(Vec3.min(this.min, box.min), Vec3.max(this.max, box.max));
    }
}
