package eu.jonahbauer.raytracing.scene;

import eu.jonahbauer.raytracing.math.AABB;
import eu.jonahbauer.raytracing.math.Range;
import eu.jonahbauer.raytracing.math.Ray;
import eu.jonahbauer.raytracing.math.Vec3;
import eu.jonahbauer.raytracing.scene.transform.RotateY;
import eu.jonahbauer.raytracing.scene.transform.Translate;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

public interface Hittable {

    /**
     * {@return the value <code>t</code> such that <code>ray.at(t)</code> is the intersection of this shaped closest to
     * the ray origin, or <code>Double.NaN</code> if the ray does not intersect this shape}
     * @param ray a ray
     */
    @NotNull Optional<HitResult> hit(@NotNull Ray ray, @NotNull Range range);

    @NotNull AABB getBoundingBox();

    default @NotNull Hittable translate(@NotNull Vec3 offset) {
        return new Translate(this, offset);
    }

    default @NotNull Hittable rotateY(double angle) {
        return new RotateY(this, angle);
    }
}
