package eu.jonahbauer.raytracing.math;

import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public record Ray(@NotNull Vec3 origin, @NotNull Vec3 direction) {
    public Ray {
        Objects.requireNonNull(origin, "origin");
        Objects.requireNonNull(direction, "direction");
    }

    public @NotNull Vec3 at(double t) {
        return new Vec3(
                origin().x() + t * direction.x(),
                origin().y() + t * direction.y(),
                origin().z() + t * direction.z()
        );
    }
}
