package eu.jonahbauer.raytracing.scene.hittable2d;

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

public final class Triangle extends Hittable2D {
    private final @NotNull AABB bbox;

    public Triangle(@NotNull Vec3 origin, @NotNull Vec3 u, @NotNull Vec3 v, @NotNull Material material) {
        super(origin, u, v, material);
        this.bbox = new AABB(origin, origin.plus(u).plus(v));
    }

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

    @Override
    public @NotNull AABB getBoundingBox() {
        return bbox;
    }
}
