public TrackDesign create() { length = 0.0; for (TrackSection section : sections) { length += section.getLength(); section.setLengthUntilEnd(length); radialIndex.put(length, section); } calculateBoundaryBox(); return this; }
private void calculateBoundaryBox() { double x = 0, y = 0; double xl = 0, xr = 0; double yu = 0, yl = 0; for (TrackSection section : sections) { x = section.getInitialAnchor().getPosX(); y = section.getInitialAnchor().getPosY(); xl = Math.min(x, xl); yu = Math.min(y, yu); xr = Math.max(x, xr); yl = Math.max(y, yl); } initialAnchor = new Anchor(0, -xl, -yu); boundarywidth = xr - xl; boudaryHeight = yl - yu; }
public Anchor findAnchorAt(double position) { TrackSection section = findSectionAt(position); return section.findAnchorAt(position); }