import Vector from '../../../math/Vector'; import Ray from '../../../utils/Ray'; import Steerable from '../../Steerable'; import RayConfiguration from '../RayConfiguration'; /** * {@code RayConfigurationBase} is the base class for concrete ray configurations having a fixed number of rays. * * @param Type of vector, either 2D or 3D, implementing the {@link Vector} interface * * @author davebaol */ abstract class RayConfigurationBase> implements RayConfiguration { protected owner: Steerable; protected rays: Ray[]; /** * Creates a {@code RayConfigurationBase} for the given owner and the specified number of rays. * @param owner the owner of this configuration * @param numRays the number of rays used by this configuration */ public constructor(owner: Steerable, numRays: number) { this.owner = owner; this.rays = []; for (let i = 0; i < numRays; i++) this.rays.push( new Ray(owner.getPosition().clone().setZero(), owner.getPosition().clone().setZero()) ); } /** Returns the owner of this configuration. */ public getOwner(): Steerable { return this.owner; } /** Sets the owner of this configuration. */ public setOwner(owner: Steerable ): void { this.owner = owner; } /** Returns the rays of this configuration. */ public getRays(): Ray[] { return this.rays; } /** Sets the rays of this configuration. */ public setRays(rays: Ray[]): void { this.rays = rays; } abstract updateRays(): Ray[]; } export default RayConfigurationBase;