trackeditor: calculate segment elevations the same way as speed dreams
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9267 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
parent
ab8edd4925
commit
983b3e874f
|
@ -373,7 +373,7 @@ public class CheckDialog extends JDialog
|
|||
{
|
||||
textArea.append(segmentInfo + "Banking start angle and banking from heights\n");
|
||||
|
||||
double bankingFromHeights = Math.atan2(heightStartLeft - heightStartRight, width) * 180.0 / Math.PI;
|
||||
double bankingFromHeights = Math.toDegrees(Math.atan2(heightStartLeft - heightStartRight, width));
|
||||
|
||||
if (bankingStart != bankingFromHeights)
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ public class CheckDialog extends JDialog
|
|||
{
|
||||
textArea.append(segmentInfo + "Banking end angle and banking from heights\n");
|
||||
|
||||
double bankingFromHeights = Math.atan2(heightEndLeft - heightEndRight, width) * 180.0 / Math.PI;
|
||||
double bankingFromHeights = Math.toDegrees(Math.atan2(heightEndLeft - heightEndRight, width));
|
||||
|
||||
if (bankingEnd != bankingFromHeights)
|
||||
{
|
||||
|
|
|
@ -959,88 +959,112 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
|
|||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
double startLeft = heightStartLeftSlider.getValue();
|
||||
double startRight = heightStartRightSlider.getValue();
|
||||
shape.setHeightStart(shape.getCalculatedHeightStart());
|
||||
slider.setValue(shape.getHeightStart());
|
||||
|
||||
if (!Double.isNaN(startLeft) &&!Double.isNaN(startRight) && startLeft == startRight)
|
||||
{
|
||||
heightStartSlider.setValue(startLeft);
|
||||
}
|
||||
shape.setHeightStartLeft(Double.NaN);
|
||||
heightStartLeftSlider.setValue(shape.getHeightStartLeft());
|
||||
|
||||
if (!Double.isNaN(startLeft))
|
||||
{
|
||||
heightStartLeftSlider.setValue(Double.NaN);
|
||||
}
|
||||
if (!Double.isNaN(startRight))
|
||||
{
|
||||
heightStartRightSlider.setValue(Double.NaN);
|
||||
}
|
||||
shape.setHeightStartRight(Double.NaN);
|
||||
heightStartRightSlider.setValue(shape.getHeightStartRight());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("L Height") && slider.getAttr().equals("Start"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
if (!Double.isNaN(heightStartSlider.getValue()))
|
||||
{
|
||||
slider.setValue(heightStartSlider.getValue());
|
||||
heightStartSlider.setValue(Double.NaN);
|
||||
}
|
||||
shape.setHeightStartLeft(shape.getCalculatedHeightStartLeft());
|
||||
slider.setValue(shape.getHeightStartLeft());
|
||||
|
||||
shape.setHeightStart(Double.NaN);
|
||||
heightStartSlider.setValue(shape.getHeightStart());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("R Height") && slider.getAttr().equals("Start"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
if (!Double.isNaN(heightStartSlider.getValue()))
|
||||
{
|
||||
slider.setValue(heightStartSlider.getValue());
|
||||
heightStartSlider.setValue(Double.NaN);
|
||||
}
|
||||
shape.setHeightStartRight(shape.getCalculatedHeightStartRight());
|
||||
slider.setValue(shape.getHeightStartRight());
|
||||
|
||||
shape.setHeightStart(Double.NaN);
|
||||
heightStartSlider.setValue(shape.getHeightStart());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("Height") && slider.getAttr().equals("End"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
double endLeft = heightEndLeftSlider.getValue();
|
||||
double endRight = heightEndRightSlider.getValue();
|
||||
shape.setHeightEnd(shape.getCalculatedHeightEnd());
|
||||
slider.setValue(shape.getHeightEnd());
|
||||
|
||||
if (!Double.isNaN(endLeft) &&!Double.isNaN(endRight) && endLeft == endRight)
|
||||
{
|
||||
heightEndSlider.setValue(endLeft);
|
||||
}
|
||||
shape.setHeightEndLeft(Double.NaN);
|
||||
heightEndLeftSlider.setValue(shape.getHeightEndLeft());
|
||||
|
||||
if (!Double.isNaN(endLeft))
|
||||
{
|
||||
heightEndLeftSlider.setValue(Double.NaN);
|
||||
}
|
||||
if (!Double.isNaN(endRight))
|
||||
{
|
||||
heightEndRightSlider.setValue(Double.NaN);
|
||||
}
|
||||
shape.setHeightEndRight(Double.NaN);
|
||||
heightEndRightSlider.setValue(shape.getHeightEndRight());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("L Height") && slider.getAttr().equals("End"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
if (!Double.isNaN(heightEndSlider.getValue()))
|
||||
{
|
||||
slider.setValue(heightEndSlider.getValue());
|
||||
heightEndSlider.setValue(Double.NaN);
|
||||
}
|
||||
shape.setHeightEndLeft(shape.getCalculatedHeightEndLeft());
|
||||
slider.setValue(shape.getHeightEndLeft());
|
||||
|
||||
shape.setHeightEnd(Double.NaN);
|
||||
heightEndSlider.setValue(shape.getHeightEnd());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("R Height") && slider.getAttr().equals("End"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
if (!Double.isNaN(heightEndSlider.getValue()))
|
||||
{
|
||||
slider.setValue(heightEndSlider.getValue());
|
||||
heightEndSlider.setValue(Double.NaN);
|
||||
}
|
||||
shape.setHeightEndRight(shape.getCalculatedHeightEndRight());
|
||||
slider.setValue(shape.getHeightEndRight());
|
||||
|
||||
shape.setHeightEnd(Double.NaN);
|
||||
heightEndSlider.setValue(shape.getHeightEnd());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("Grade") && slider.getAttr().equals(""))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
shape.setGrade(shape.getCalculatedGrade());
|
||||
slider.setValue(shape.getGrade());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("Banking") && slider.getAttr().equals("Start"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
shape.setBankingStart(shape.getCalculatedBankingStart());
|
||||
slider.setValue(shape.getBankingStart());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("Banking") && slider.getAttr().equals("End"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
shape.setBankingEnd(shape.getCalculatedBankingEnd());
|
||||
slider.setValue(shape.getBankingEnd());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("Tangent") && slider.getAttr().equals("Start"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
shape.setProfilStartTangent(shape.getCalculatedStartTangent());
|
||||
slider.setValue(shape.getProfilStartTangent());
|
||||
}
|
||||
}
|
||||
else if (slider.getSection().equals("Tangent") && slider.getAttr().equals("End"))
|
||||
{
|
||||
if (slider.isCheckBoxSelected())
|
||||
{
|
||||
shape.setProfilEndTangent(shape.getCalculatedEndTangent());
|
||||
slider.setValue(shape.getProfilEndTangent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SegmentSlider extends JPanel
|
|||
private double defaultValue;
|
||||
private double resolution;
|
||||
private String method;
|
||||
private double value = Double.NaN;;
|
||||
private double value = Double.NaN;
|
||||
private NumberFormat nf;
|
||||
|
||||
/**
|
||||
|
|
|
@ -655,7 +655,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
newShape.getRight().setBarrierWidth(oldShape.getRight().getBarrierWidth());
|
||||
|
||||
double heightStart = oldShape.getValidHeightStart();
|
||||
|
||||
|
||||
if (!Double.isNaN(heightStart) && oldShape.hasHeightEnd())
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEnd());
|
||||
|
@ -681,7 +681,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
}
|
||||
|
||||
double bankingStart = oldShape.getValidBankingStart(editorFrame);
|
||||
|
||||
|
||||
if (!Double.isNaN(bankingStart) && oldShape.hasBankingEnd())
|
||||
{
|
||||
newShape.setBankingEnd(oldShape.getBankingEnd());
|
||||
|
@ -690,13 +690,11 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
oldShape.setBankingEnd(banking);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(oldShape.getProfilStartTangent()) && !Double.isNaN(oldShape.getProfilEndTangent()))
|
||||
if (oldShape.hasProfilStartTangent() || oldShape.hasProfilEndTangent())
|
||||
{
|
||||
newShape.setProfilEndTangent(oldShape.getProfilEndTangent());
|
||||
// TODO calculate the slope at the split point
|
||||
double tangent = oldShape.getProfilStartTangent() + (oldShape.getProfilEndTangent() - oldShape.getProfilStartTangent()) * splitPoint;
|
||||
newShape.setProfilStartTangent(tangent);
|
||||
oldShape.setProfilEndTangent(tangent);
|
||||
newShape.setProfilStartTangent(oldShape.getCalculatedGrade());
|
||||
oldShape.setProfilEndTangent(oldShape.getCalculatedGrade());
|
||||
}
|
||||
|
||||
newShape.setGrade(oldShape.getGrade());
|
||||
|
@ -2166,6 +2164,8 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
if (editorFrame.getTrackData() == null)
|
||||
return;
|
||||
|
||||
editorFrame.getTrackData().calculateSegmentValues();
|
||||
|
||||
SegmentVector track = editorFrame.getTrackData().getSegments();
|
||||
|
||||
if (track == null)
|
||||
|
|
|
@ -212,6 +212,7 @@ public class XmlReader
|
|||
setCameras(root);
|
||||
setMainTrack(root);
|
||||
setSectors(root);
|
||||
editorFrame.getTrackData().calculateSegmentValues();
|
||||
}
|
||||
|
||||
private synchronized void setMainTrack(Element root)
|
||||
|
@ -1165,7 +1166,7 @@ public class XmlReader
|
|||
}
|
||||
else if (expectedUnit.equals("rad") && actualUnit.equals("deg"))
|
||||
{
|
||||
out = out * Math.PI / 180.0;
|
||||
out = Math.toRadians(out);
|
||||
}
|
||||
else if (expectedUnit.equals("s") && (actualUnit.equals("hour") || actualUnit.equals("hours")))
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Properties
|
|||
private static Properties instance = new Properties();
|
||||
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
|
||||
public final String title = "sd2-trackeditor";
|
||||
public final String version = "1.4.12";
|
||||
public final String version = "1.4.13";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
|
@ -135,6 +135,17 @@ public class SegmentVector extends Vector<Segment>
|
|||
}
|
||||
}
|
||||
|
||||
public void dumpCalculated(String indent)
|
||||
{
|
||||
System.out.println(indent + "Track Segments");
|
||||
|
||||
for (int i = 0; i < size(); i++)
|
||||
{
|
||||
System.out.println(indent + " segment[" + i + "]");
|
||||
get(i).dumpCalculated(indent + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpLinks()
|
||||
{
|
||||
for (int i = 0; i < size(); i++)
|
||||
|
|
|
@ -23,6 +23,7 @@ package utils;
|
|||
import java.util.Vector;
|
||||
|
||||
import utils.circuit.Camera;
|
||||
import utils.circuit.Curve;
|
||||
import utils.circuit.Graphic;
|
||||
import utils.circuit.GraphicObject;
|
||||
import utils.circuit.Header;
|
||||
|
@ -31,6 +32,7 @@ import utils.circuit.MainTrack;
|
|||
import utils.circuit.ObjectMap;
|
||||
import utils.circuit.Reliefs;
|
||||
import utils.circuit.Sector;
|
||||
import utils.circuit.Segment;
|
||||
import utils.circuit.StartingGrid;
|
||||
import utils.circuit.Surface;
|
||||
import utils.circuit.TerrainGeneration;
|
||||
|
@ -246,4 +248,190 @@ public final class TrackData
|
|||
{
|
||||
return getGraphic().getTerrainGeneration().getGraphicObjects();
|
||||
}
|
||||
|
||||
public void calculateSegmentValues()
|
||||
{
|
||||
double width = mainTrack.getWidth();
|
||||
boolean hasGrade = false;
|
||||
|
||||
for (int i = 0; i < segments.size(); i++)
|
||||
{
|
||||
Segment segment = segments.get(i);
|
||||
boolean hasSpline = (segment.hasProfil() && segment.getProfil().equals("spline")) ||
|
||||
mainTrack.getProfil() == null ||
|
||||
mainTrack.getProfil().equals("spline");
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
segment.setCalculatedHeightStart(0);
|
||||
segment.setCalculatedHeightStartLeft(0);
|
||||
segment.setCalculatedHeightStartRight(0);
|
||||
segment.setCalculatedHeightEnd(0);
|
||||
segment.setCalculatedHeightEndLeft(0);
|
||||
segment.setCalculatedHeightEndRight(0);
|
||||
segment.setCalculatedGrade(0);
|
||||
segment.setCalculatedBankingStart(0);
|
||||
segment.setCalculatedBankingEnd(0);
|
||||
segment.setCalculatedStartTangent(0);
|
||||
segment.setCalculatedEndTangent(0);
|
||||
segment.setCalculatedStartTangentLeft(0);
|
||||
segment.setCalculatedEndTangentLeft(0);
|
||||
segment.setCalculatedStartTangentRight(0);
|
||||
segment.setCalculatedEndTangentRight(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Segment previous = segment.getPreviousShape();
|
||||
|
||||
segment.setCalculatedHeightStartLeft(previous.getCalculatedHeightEndLeft());
|
||||
segment.setCalculatedHeightStartRight(previous.getCalculatedHeightEndRight());
|
||||
segment.setCalculatedHeightEndLeft(previous.getCalculatedHeightEndLeft());
|
||||
segment.setCalculatedHeightEndRight(previous.getCalculatedHeightEndRight());
|
||||
segment.setCalculatedHeightStart(previous.getCalculatedHeightEnd());
|
||||
segment.setCalculatedHeightEnd(previous.getCalculatedHeightEnd());
|
||||
segment.setCalculatedGrade(previous.getCalculatedGrade());
|
||||
segment.setCalculatedBankingStart(previous.getCalculatedBankingEnd());
|
||||
segment.setCalculatedBankingEnd(previous.getCalculatedBankingEnd());
|
||||
|
||||
segment.setCalculatedStartTangentLeft(previous.getCalculatedEndTangentLeft());
|
||||
segment.setCalculatedStartTangentRight(previous.getCalculatedEndTangentRight());
|
||||
|
||||
if (hasSpline)
|
||||
{
|
||||
segment.setCalculatedStartTangent(previous.getCalculatedStartTangent());
|
||||
segment.setCalculatedEndTangent(previous.getCalculatedEndTangent());
|
||||
segment.setCalculatedStartTangentLeft(previous.getCalculatedStartTangentLeft());
|
||||
segment.setCalculatedEndTangentLeft(previous.getCalculatedEndTangentLeft());
|
||||
segment.setCalculatedStartTangentRight(previous.getCalculatedStartTangentRight());
|
||||
segment.setCalculatedEndTangentRight(previous.getCalculatedEndTangentRight());
|
||||
}
|
||||
}
|
||||
|
||||
double length;
|
||||
if (segment.getType().equals("str"))
|
||||
{
|
||||
length = segment.getLength();
|
||||
}
|
||||
else
|
||||
{
|
||||
Curve curve = (Curve) segment;
|
||||
double radiusEnd;
|
||||
|
||||
if (curve.hasRadiusEnd())
|
||||
radiusEnd = curve.getRadiusEnd();
|
||||
else
|
||||
radiusEnd = curve.getRadiusStart();
|
||||
|
||||
length = ((curve.getRadiusStart() + radiusEnd) / 2.0 * curve.getArcRad());
|
||||
}
|
||||
|
||||
if (segment.hasHeightStartLeft())
|
||||
segment.setCalculatedHeightStartLeft(segment.getHeightStartLeft());
|
||||
|
||||
if (segment.hasHeightStartRight())
|
||||
segment.setCalculatedHeightStartRight(segment.getHeightStartRight());
|
||||
|
||||
if (segment.hasHeightEndLeft())
|
||||
segment.setCalculatedHeightEndLeft(segment.getHeightEndLeft());
|
||||
|
||||
if (segment.hasHeightEndRight())
|
||||
segment.setCalculatedHeightEndRight(segment.getHeightEndRight());
|
||||
|
||||
if (segment.hasGrade())
|
||||
{
|
||||
hasGrade = true;
|
||||
segment.setCalculatedGrade(segment.getGrade());
|
||||
}
|
||||
|
||||
if (segment.hasHeightStart())
|
||||
{
|
||||
segment.setCalculatedHeightStart(segment.getHeightStart());
|
||||
segment.setCalculatedHeightStartLeft(segment.getHeightStart());
|
||||
segment.setCalculatedHeightStartRight(segment.getHeightStart());
|
||||
}
|
||||
else
|
||||
{
|
||||
segment.setCalculatedHeightStart((segment.getCalculatedHeightStartLeft() + segment.getCalculatedHeightStartRight()) / 2);
|
||||
}
|
||||
|
||||
if (segment.hasHeightEnd())
|
||||
{
|
||||
segment.setCalculatedHeightEnd(segment.getHeightEnd());
|
||||
segment.setCalculatedHeightEndLeft(segment.getHeightEnd());
|
||||
segment.setCalculatedHeightEndRight(segment.getHeightEnd());
|
||||
segment.setCalculatedGrade(((segment.getCalculatedHeightEnd() - segment.getCalculatedHeightStart()) / length) * 100);
|
||||
}
|
||||
else if (hasGrade)
|
||||
{
|
||||
segment.setCalculatedHeightEnd(segment.getCalculatedHeightStart() + (length * (segment.getCalculatedGrade() / 100)));
|
||||
}
|
||||
else
|
||||
{
|
||||
segment.setCalculatedHeightEnd((segment.getCalculatedHeightEndLeft() + segment.getCalculatedHeightEndRight()) / 2);
|
||||
}
|
||||
|
||||
if (segment.hasBankingStart())
|
||||
{
|
||||
segment.setCalculatedBankingStart(segment.getBankingStart());
|
||||
}
|
||||
else
|
||||
{
|
||||
segment.setCalculatedBankingStart(Math.toDegrees(Math.atan2(segment.getCalculatedHeightStartLeft() - segment.getCalculatedHeightStartRight(), width)));
|
||||
}
|
||||
|
||||
if (segment.hasBankingEnd())
|
||||
{
|
||||
segment.setCalculatedBankingEnd(segment.getBankingEnd());
|
||||
}
|
||||
else
|
||||
{
|
||||
segment.setCalculatedBankingEnd(Math.toDegrees(Math.atan2(segment.getCalculatedHeightEndLeft() - segment.getCalculatedHeightEndRight(), width)));
|
||||
}
|
||||
|
||||
double dz = Math.tan(Math.toRadians(segment.getCalculatedBankingStart())) * width / 2;
|
||||
segment.setCalculatedHeightStartLeft(segment.getCalculatedHeightStart() + dz);
|
||||
segment.setCalculatedHeightStartRight(segment.getCalculatedHeightStart() - dz);
|
||||
dz = Math.tan(Math.toRadians(segment.getCalculatedBankingEnd())) * width / 2;
|
||||
segment.setCalculatedHeightEndLeft(segment.getCalculatedHeightEnd() + dz);
|
||||
segment.setCalculatedHeightEndRight(segment.getCalculatedHeightEnd() - dz);
|
||||
|
||||
if (hasSpline)
|
||||
{
|
||||
if (segment.hasProfilStartTangentLeft())
|
||||
segment.setCalculatedStartTangentLeft(segment.getProfilStartTangentLeft());
|
||||
if (segment.hasProfilEndTangentLeft())
|
||||
segment.setCalculatedEndTangentLeft(segment.getProfilEndTangentLeft());
|
||||
if (segment.hasProfilStartTangentRight())
|
||||
segment.setCalculatedStartTangentRight(segment.getProfilStartTangentRight());
|
||||
if (segment.hasProfilEndTangentRight())
|
||||
segment.setCalculatedEndTangentRight(segment.getProfilEndTangentRight());
|
||||
|
||||
if (segment.hasProfilStartTangent())
|
||||
{
|
||||
segment.setCalculatedStartTangent(segment.getProfilStartTangent());
|
||||
segment.setCalculatedStartTangentLeft(segment.getProfilStartTangent());
|
||||
segment.setCalculatedStartTangentRight(segment.getProfilStartTangent());
|
||||
}
|
||||
if (segment.hasProfilEndTangent())
|
||||
{
|
||||
segment.setCalculatedEndTangent(segment.getProfilEndTangent());
|
||||
segment.setCalculatedEndTangentLeft(segment.getProfilEndTangent());
|
||||
segment.setCalculatedEndTangentRight(segment.getProfilEndTangent());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
segment.setCalculatedStartTangentLeft((segment.getCalculatedHeightEndLeft() - segment.getCalculatedHeightStartLeft()) / length);
|
||||
segment.setCalculatedEndTangentLeft((segment.getCalculatedHeightEndLeft() - segment.getCalculatedHeightStartLeft()) / length);
|
||||
|
||||
segment.setCalculatedStartTangentRight((segment.getCalculatedHeightEndRight() - segment.getCalculatedHeightStartRight()) / length);
|
||||
segment.setCalculatedEndTangentRight((segment.getCalculatedHeightEndRight() - segment.getCalculatedHeightStartRight()) / length);
|
||||
|
||||
segment.setCalculatedStartTangent((segment.getCalculatedStartTangentLeft() + segment.getCalculatedStartTangentRight()) / 2);
|
||||
segment.setCalculatedEndTangent((segment.getCalculatedEndTangentLeft() + segment.getCalculatedEndTangentRight()) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
//segments.dumpCalculated("");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public class Curve extends Segment
|
|||
*/
|
||||
|
||||
// calc turn length
|
||||
double arc = arcDeg * Math.PI / 180;
|
||||
double arc = getArcRad();
|
||||
length = arc * (radiusStart + radiusEnd) / 2;
|
||||
nbSteps = (int) (length / profilStepsLength + 0.5) + 1;
|
||||
|
||||
|
@ -427,14 +427,14 @@ public class Curve extends Segment
|
|||
*/
|
||||
public double getArcRad()
|
||||
{
|
||||
return arcDeg * Math.PI / 180;
|
||||
return Math.toRadians(arcDeg);
|
||||
}
|
||||
/**
|
||||
* @param arc The arc to set.
|
||||
*/
|
||||
public void setArcRad(double arcRad)
|
||||
{
|
||||
this.arcDeg = arcRad * 180 / Math.PI;
|
||||
this.arcDeg = Math.toDegrees(arcRad);
|
||||
}
|
||||
/**
|
||||
* @return Returns the arc.
|
||||
|
@ -457,6 +457,11 @@ public class Curve extends Segment
|
|||
{
|
||||
return radiusEnd;
|
||||
}
|
||||
public boolean hasRadiusEnd()
|
||||
{
|
||||
return !Double.isNaN(radiusEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param radiusEnd The radiusEnd to set.
|
||||
*/
|
||||
|
|
|
@ -86,6 +86,23 @@ public class Segment implements Cloneable
|
|||
protected double profilStartTangentRight = Double.NaN;
|
||||
protected double profilEndTangentRight = Double.NaN;
|
||||
|
||||
// calculated values
|
||||
protected double calculatedHeightStart = Double.NaN;
|
||||
protected double calculatedHeightStartLeft = Double.NaN;
|
||||
protected double calculatedHeightStartRight = Double.NaN;
|
||||
protected double calculatedHeightEnd = Double.NaN;
|
||||
protected double calculatedHeightEndLeft = Double.NaN;
|
||||
protected double calculatedHeightEndRight = Double.NaN;
|
||||
protected double calculatedGrade = Double.NaN;
|
||||
protected double calculatedBankingStart = Double.NaN;
|
||||
protected double calculatedBankingEnd = Double.NaN;
|
||||
protected double calculatedStartTangent = Double.NaN;
|
||||
protected double calculatedEndTangent = Double.NaN;
|
||||
protected double calculatedStartTangentLeft = Double.NaN;
|
||||
protected double calculatedEndTangentLeft = Double.NaN;
|
||||
protected double calculatedStartTangentRight = Double.NaN;
|
||||
protected double calculatedEndTangentRight = Double.NaN;
|
||||
|
||||
// shape to be drawn
|
||||
public Point2D.Double points[];
|
||||
public Point2D.Double trPoints[];
|
||||
|
@ -474,7 +491,7 @@ public class Segment implements Cloneable
|
|||
{
|
||||
return !Double.isNaN(heightEndRight);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the grade.
|
||||
*/
|
||||
|
@ -490,6 +507,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.grade = grade;
|
||||
}
|
||||
public boolean hasGrade()
|
||||
{
|
||||
return !Double.isNaN(grade);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the bankingStart.
|
||||
*/
|
||||
|
@ -545,6 +567,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profil = profil;
|
||||
}
|
||||
public boolean hasProfil()
|
||||
{
|
||||
return profil != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilSteps.
|
||||
*/
|
||||
|
@ -560,6 +587,10 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilSteps = profilSteps;
|
||||
}
|
||||
public boolean hasProfilSteps()
|
||||
{
|
||||
return !Double.isNaN(profilSteps);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilStepsLength.
|
||||
|
@ -636,6 +667,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilStartTangentLeft = profilStartTangentLeft;
|
||||
}
|
||||
public boolean hasProfilStartTangentLeft()
|
||||
{
|
||||
return !Double.isNaN(profilStartTangentLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilEndTangentLeft.
|
||||
*/
|
||||
|
@ -651,6 +687,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilEndTangentLeft = profilEndTangentLeft;
|
||||
}
|
||||
public boolean hasProfilEndTangentLeft()
|
||||
{
|
||||
return !Double.isNaN(profilEndTangentLeft);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilStartTangentRight.
|
||||
*/
|
||||
|
@ -666,6 +707,11 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilStartTangentRight = profilStartTangentRight;
|
||||
}
|
||||
public boolean hasProfilStartTangentRight()
|
||||
{
|
||||
return !Double.isNaN(profilStartTangentRight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the profilEndTangentRight.
|
||||
*/
|
||||
|
@ -681,6 +727,10 @@ public class Segment implements Cloneable
|
|||
{
|
||||
this.profilEndTangentRight = profilEndTangentRight;
|
||||
}
|
||||
public boolean hasProfilEndTangentRight()
|
||||
{
|
||||
return !Double.isNaN(profilEndTangentRight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the length.
|
||||
|
@ -855,6 +905,141 @@ public class Segment implements Cloneable
|
|||
return dy;
|
||||
}
|
||||
|
||||
public double getCalculatedHeightStart()
|
||||
{
|
||||
return calculatedHeightStart;
|
||||
}
|
||||
public void setCalculatedHeightStart(double calculatedHeightStart)
|
||||
{
|
||||
this.calculatedHeightStart = calculatedHeightStart;
|
||||
}
|
||||
|
||||
public double getCalculatedHeightStartLeft()
|
||||
{
|
||||
return calculatedHeightStartLeft;
|
||||
}
|
||||
public void setCalculatedHeightStartLeft(double calculatedHeightStartLeft)
|
||||
{
|
||||
this.calculatedHeightStartLeft = calculatedHeightStartLeft;
|
||||
}
|
||||
|
||||
public double getCalculatedHeightStartRight()
|
||||
{
|
||||
return calculatedHeightStartRight;
|
||||
}
|
||||
public void setCalculatedHeightStartRight(double calculatedHeightStartRight)
|
||||
{
|
||||
this.calculatedHeightStartRight = calculatedHeightStartRight;
|
||||
}
|
||||
|
||||
public double getCalculatedHeightEnd()
|
||||
{
|
||||
return calculatedHeightEnd;
|
||||
}
|
||||
public void setCalculatedHeightEnd(double calculatedHeightEnd)
|
||||
{
|
||||
this.calculatedHeightEnd = calculatedHeightEnd;
|
||||
}
|
||||
|
||||
public double getCalculatedHeightEndLeft()
|
||||
{
|
||||
return calculatedHeightEndLeft;
|
||||
}
|
||||
public void setCalculatedHeightEndLeft(double calculatedHeightEndLeft)
|
||||
{
|
||||
this.calculatedHeightEndLeft = calculatedHeightEndLeft;
|
||||
}
|
||||
|
||||
public double getCalculatedHeightEndRight()
|
||||
{
|
||||
return calculatedHeightEndRight;
|
||||
}
|
||||
public void setCalculatedHeightEndRight(double calculatedHeightEndRight)
|
||||
{
|
||||
this.calculatedHeightEndRight = calculatedHeightEndRight;
|
||||
}
|
||||
|
||||
public double getCalculatedGrade()
|
||||
{
|
||||
return calculatedGrade;
|
||||
}
|
||||
public void setCalculatedGrade(double calculatedGrade)
|
||||
{
|
||||
this.calculatedGrade = calculatedGrade;
|
||||
}
|
||||
|
||||
public double getCalculatedBankingStart()
|
||||
{
|
||||
return calculatedBankingStart;
|
||||
}
|
||||
public void setCalculatedBankingStart(double calculatedBankingStart)
|
||||
{
|
||||
this.calculatedBankingStart = calculatedBankingStart;
|
||||
}
|
||||
|
||||
public double getCalculatedBankingEnd()
|
||||
{
|
||||
return calculatedBankingEnd;
|
||||
}
|
||||
public void setCalculatedBankingEnd(double calculatedBankingEnd)
|
||||
{
|
||||
this.calculatedBankingEnd = calculatedBankingEnd;
|
||||
}
|
||||
|
||||
public double getCalculatedStartTangent()
|
||||
{
|
||||
return calculatedStartTangent;
|
||||
}
|
||||
public void setCalculatedStartTangent(double calculatedStartTangent)
|
||||
{
|
||||
this.calculatedStartTangent = calculatedStartTangent;
|
||||
}
|
||||
|
||||
public double getCalculatedEndTangent()
|
||||
{
|
||||
return calculatedEndTangent;
|
||||
}
|
||||
public void setCalculatedEndTangent(double calculatedEndTangent)
|
||||
{
|
||||
this.calculatedEndTangent = calculatedEndTangent;
|
||||
}
|
||||
|
||||
public double getCalculatedStartTangentLeft()
|
||||
{
|
||||
return calculatedStartTangentLeft;
|
||||
}
|
||||
public void setCalculatedStartTangentLeft(double calculatedStartTangentLeft)
|
||||
{
|
||||
this.calculatedStartTangentLeft = calculatedStartTangentLeft;
|
||||
}
|
||||
|
||||
public double getCalculatedEndTangentLeft()
|
||||
{
|
||||
return calculatedEndTangentLeft;
|
||||
}
|
||||
public void setCalculatedEndTangentLeft(double calculatedEndTangentLeft)
|
||||
{
|
||||
this.calculatedEndTangentLeft = calculatedEndTangentLeft;
|
||||
}
|
||||
|
||||
public double getCalculatedStartTangentRight()
|
||||
{
|
||||
return calculatedStartTangentRight;
|
||||
}
|
||||
public void setCalculatedStartTangentRight(double calculatedStartTangentRight)
|
||||
{
|
||||
this.calculatedStartTangentRight = calculatedStartTangentRight;
|
||||
}
|
||||
|
||||
public double getCalculatedEndTangentRight()
|
||||
{
|
||||
return calculatedEndTangentRight;
|
||||
}
|
||||
public void setCalculatedEndTangentRight(double calculatedEndTangentRight)
|
||||
{
|
||||
this.calculatedEndTangentRight = calculatedEndTangentRight;
|
||||
}
|
||||
|
||||
public String getValidSurface(EditorFrame editorFrame)
|
||||
{
|
||||
Segment previous = this;
|
||||
|
@ -1906,7 +2091,7 @@ public class Segment implements Cloneable
|
|||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(previous.heightStartLeft - previous.heightStartRight, editorFrame.getTrackData().getMainTrack().getWidth()) * 180.0 / Math.PI;
|
||||
return Math.toDegrees(Math.atan2(previous.heightStartLeft - previous.heightStartRight, editorFrame.getTrackData().getMainTrack().getWidth()));
|
||||
}
|
||||
}
|
||||
previous = previous.previousShape;
|
||||
|
@ -1930,7 +2115,7 @@ public class Segment implements Cloneable
|
|||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(previous.heightEndLeft - previous.heightEndRight, editorFrame.getTrackData().getMainTrack().getWidth()) * 180.0 / Math.PI;
|
||||
return Math.toDegrees(Math.atan2(previous.heightEndLeft - previous.heightEndRight, editorFrame.getTrackData().getMainTrack().getWidth()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2038,6 +2223,27 @@ public class Segment implements Cloneable
|
|||
right.setSideBankingType(getValidRightSideBankingType(editorFrame));
|
||||
}
|
||||
|
||||
public void dumpCalculated(String indent)
|
||||
{
|
||||
System.out.println(indent + "name : " + name);
|
||||
System.out.println(indent + "type : " + type);
|
||||
System.out.println(indent + "calculatedHeightStart : " + calculatedHeightStart);
|
||||
System.out.println(indent + "calculatedHeightStartLeft : " + calculatedHeightStartLeft);
|
||||
System.out.println(indent + "calculatedHeightStartRight : " + calculatedHeightStartRight);
|
||||
System.out.println(indent + "calculatedHeightEnd : " + calculatedHeightEndLeft);
|
||||
System.out.println(indent + "calculatedHeightEndLeft : " + calculatedHeightEndLeft);
|
||||
System.out.println(indent + "calculatedHeightEndRight : " + calculatedHeightEndRight);
|
||||
System.out.println(indent + "calculatedGrade : " + calculatedGrade);
|
||||
System.out.println(indent + "calculatedBankingStart : " + calculatedBankingStart);
|
||||
System.out.println(indent + "calculatedBankingEnd : " + calculatedBankingEnd);
|
||||
System.out.println(indent + "calculatedStartTangent : " + calculatedStartTangent);
|
||||
System.out.println(indent + "calculatedStartTangentLeft : " + calculatedStartTangentLeft);
|
||||
System.out.println(indent + "calculatedStartTangentRight : " + calculatedStartTangentRight);
|
||||
System.out.println(indent + "calculatedEndTangent : " + calculatedEndTangent);
|
||||
System.out.println(indent + "calculatedEndTangentLeft : " + calculatedEndTangentLeft);
|
||||
System.out.println(indent + "calculatedEndTangentRight : " + calculatedEndTangentRight);
|
||||
}
|
||||
|
||||
public void dump(String indent)
|
||||
{
|
||||
System.out.println(indent + "Segment");
|
||||
|
|
Loading…
Reference in New Issue