import { Vector } from "@bearmetal/doodler"; import { TrackSegment } from "./system.ts"; export class StraightTrack extends TrackSegment { constructor(start?: Vector) { start = start || new Vector(100, 100); super([ start, start.copy().add(25, 0), start.copy().add(75, 0), start.copy().add(100, 0), ]); } } export class SBendLeft extends TrackSegment { constructor(start?: Vector) { start = start || new Vector(100, 100); super([ start, start.copy().add(60, 0), start.copy().add(90, -25), start.copy().add(150, -25), ]); } } export class SBendRight extends TrackSegment { constructor(start?: Vector) { start = start || new Vector(100, 100); super([ start, start.copy().add(60, 0), start.copy().add(90, 25), start.copy().add(150, 25), ]); } } export class BankLeft extends TrackSegment { constructor(start?: Vector) { start = start || new Vector(100, 100); const p1 = start.copy(); const p2 = start.copy(); const p3 = start.copy(); const p4 = start.copy(); const scale = 33; p2.add(new Vector(1, 0).mult(scale)); p3.set(p2); const dirToP3 = Vector.fromAngle(-Math.PI / 12).mult(scale); p3.add(dirToP3); p4.set(p3); const dirToP4 = Vector.fromAngle(-Math.PI / 6).mult(scale); p4.add(dirToP4); super([ p1, p2, p3, p4, ]); } } export class BankRight extends TrackSegment { constructor(start?: Vector) { start = start || new Vector(100, 100); const p1 = start.copy(); const p2 = start.copy(); const p3 = start.copy(); const p4 = start.copy(); const scale = 33; p2.add(new Vector(1, 0).mult(scale)); p3.set(p2); const dirToP3 = Vector.fromAngle(Math.PI / 12).mult(scale); p3.add(dirToP3); p4.set(p3); const dirToP4 = Vector.fromAngle(Math.PI / 6).mult(scale); p4.add(dirToP4); super([ p1, p2, p3, p4, ]); } }