import '../../assert/js/assert.js';
import '../../globals.js';
// Copyright 2013-2024, University of Colorado Boulder
/**
 * 2-dimensional ray consisting of an origin point and a unit direction vector.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import dot from './dot.js';
export default class Ray2 {
    /**
     * Constructs a2D ray using the supplied origin position and unit length direction vector
     *
     * @param position - the ray's point of origin
     * @param direction - the ray's unit direction vector
     */
    constructor(position, direction) {
        this.position = position;
        this.direction = direction;
        assert && assert(Math.abs(direction.magnitude - 1) < 0.01, 'the direction must be a unit vector');
    }
    /**
     * Returns a new Ray that has it origin shifted to a position given by an amount distance*this.direction.
     */
    shifted(distance) {
        return new Ray2(this.pointAtDistance(distance), this.direction);
    }
    /**
     * Returns a position that is a distance 'distance' along the ray.
     */
    pointAtDistance(distance) {
        return this.position.plus(this.direction.timesScalar(distance));
    }
    /**
     * Returns the attributes of this ray into a string
     */
    toString() {
        return `${this.position.toString()} => ${this.direction.toString()}`;
    }
}
dot.register('Ray2', Ray2);
//# sourceMappingURL=Ray2.js.map