// A ray defined by an origin and a (not necessarily normalized) direction.

import { Vec3, type Vec3Like } from "../math/vec"

export class Ray {
  readonly origin: Vec3
  readonly dir: Vec3

  constructor(origin: Vec3Like, dir: Vec3Like) {
    this.origin = new Vec3(origin)
    this.dir = new Vec3(dir)
  }

  /** The world-space point origin + t·dir. */
  getPoint(t: number): Vec3 { return this.origin.scaleAndAdd(this.dir, t) }
}
