package eu.jonahbauer.raytracing.scene.hittable2d;

import eu.jonahbauer.raytracing.math.BoundingBox;
import eu.jonahbauer.raytracing.math.Vec3;
import eu.jonahbauer.raytracing.render.material.Material;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

public final class Ellipse extends Hittable2D {
    public Ellipse(@NotNull Vec3 origin, @NotNull Vec3 u, @NotNull Vec3 v, @NotNull Material material) {
        super(origin, u, v, material);
    }

    @Override
    protected boolean isInterior(double alpha, double beta) {
        return alpha * alpha + beta * beta < 1;
    }

    @Override
    public @NotNull Optional<BoundingBox> getBoundingBox() {
        var a = origin.minus(u).minus(v);
        var b = origin.plus(u).plus(v);
        return Optional.of(new BoundingBox(Vec3.min(a, b), Vec3.max(a, b)));
    }
}
