const std = @import("std");
const vec = @import("./vec.zig");

const Vec3 = vec.Vec3;
const Point3 = vec.Point3;

pub const Ray = struct {
    orig: Vec3,
    dir: Vec3,

    pub fn init(orig: Point3, dir: Vec3) Ray {
        return Ray{
            .orig = orig,
            .dir = dir,
        };
    }
    pub fn origin(ray: Ray) Point3 {
        return ray.orig;
    }
    pub fn direction(ray: Ray) Vec3 {
        return ray.dir;
    }
    pub fn at(ray: Ray, t: f32) Point3 {
        return ray.orig.add(ray.dir.scale(t));
    }
};

test "ray_at" {
    const want = Point3.init(0, 0, 1.5);
    const r = Ray.init(Point3.init(0, 0, 0), Vec3.init(0, 0, 1));
    const got = r.at(1.5);
    try std.testing.expectEqual(want, got);
}
