trackeditor: fix import export differences from degree to radian to degree conversions

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8483 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 52624b6a4606ce6a6196b3c9a23de42c7af42d1b
Former-commit-id: 22bb8d638d8dc60764516707c030ae7b77f352de
This commit is contained in:
iobyte 2022-09-10 18:10:23 +00:00
parent b65df99736
commit 8eb900d612
7 changed files with 31 additions and 18 deletions

View file

@ -471,7 +471,7 @@ public class DeltaPanel extends JDialog implements Runnable
if(!obj.getType().equals("str")) if(!obj.getType().equals("str"))
{ {
Curve curve = (Curve) obj; Curve curve = (Curve) obj;
curve.setArc(curve.getArc()*co); curve.setArcRad(curve.getArcRad()*co);
} }
} catch (Exception e) } catch (Exception e)
{ {

View file

@ -583,7 +583,7 @@ public class EditorFrame extends JFrame
shape = new Curve(); shape = new Curve();
((Curve)shape).setRadiusStart(100); ((Curve)shape).setRadiusStart(100);
((Curve)shape).setRadiusEnd(100); ((Curve)shape).setRadiusEnd(100);
((Curve)shape).setArc(Math.PI); ((Curve)shape).setArcDeg(180);
shape.setHeightStartLeft(0); shape.setHeightStartLeft(0);
shape.setHeightStartRight(0); shape.setHeightStartRight(0);
shape.setHeightEndLeft(0); shape.setHeightEndLeft(0);
@ -611,7 +611,7 @@ public class EditorFrame extends JFrame
shape = new Curve(); shape = new Curve();
((Curve)shape).setRadiusStart(100); ((Curve)shape).setRadiusStart(100);
((Curve)shape).setRadiusEnd(100); ((Curve)shape).setRadiusEnd(100);
((Curve)shape).setArc(Math.PI); ((Curve)shape).setArcDeg(180);
shape.setHeightStartLeft(0); shape.setHeightStartLeft(0);
shape.setHeightStartRight(0); shape.setHeightStartRight(0);
shape.setHeightEndLeft(0); shape.setHeightEndLeft(0);

View file

@ -355,10 +355,10 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
arcSlider.setMax(360); arcSlider.setMax(360);
arcSlider.setExtent(10); arcSlider.setExtent(10);
arcSlider.setTickSpacing(1); arcSlider.setTickSpacing(1);
arcSlider.setRealToTextCoeff(180/Math.PI); arcSlider.setRealToTextCoeff(1);
if (!shape.getType().equals("str")) if (!shape.getType().equals("str"))
{ {
arcSlider.setMethod("Arc"); arcSlider.setMethod("ArcDeg");
} }
arcSlider.addSliderListener(this); arcSlider.addSliderListener(this);
} }
@ -770,7 +770,7 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
getGroupButton().setEnabled(true); getGroupButton().setEnabled(true);
getGroupButton().setSelected(curve.getType()); getGroupButton().setSelected(curve.getType());
this.getArcSlider().setValue(curve.getArc()); this.getArcSlider().setValue(curve.getArcDeg());
this.getRadiusStartSlider().setValue(curve.getRadiusStart()); this.getRadiusStartSlider().setValue(curve.getRadiusStart());
this.getRadiusEndSlider().setValue(curve.getRadiusEnd()); this.getRadiusEndSlider().setValue(curve.getRadiusEnd());
this.getMarksTextField().setEnabled(true); this.getMarksTextField().setEnabled(true);

View file

@ -260,7 +260,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
Vector<Segment> data = editorFrame.getTrackData().getSegments(); Vector<Segment> data = editorFrame.getTrackData().getSegments();
int pos = data.indexOf(handledShape); int pos = data.indexOf(handledShape);
Curve newShape = new Curve("lft",handledShape); Curve newShape = new Curve("lft",handledShape);
newShape.setArc(Math.PI/2); newShape.setArcDeg(90);
newShape.setRadiusStart(50); newShape.setRadiusStart(50);
newShape.setRadiusEnd(50); newShape.setRadiusEnd(50);
newShape.inheritProperties(handledShape); newShape.inheritProperties(handledShape);
@ -289,7 +289,7 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
Vector<Segment> data = editorFrame.getTrackData().getSegments(); Vector<Segment> data = editorFrame.getTrackData().getSegments();
int pos = data.indexOf(handledShape); int pos = data.indexOf(handledShape);
Curve newShape = new Curve("rgt",handledShape); Curve newShape = new Curve("rgt",handledShape);
newShape.setArc(Math.PI/2); newShape.setArcDeg(90);
newShape.setRadiusStart(50); newShape.setRadiusStart(50);
newShape.setRadiusEnd(50); newShape.setRadiusEnd(50);
newShape.inheritProperties(handledShape); newShape.inheritProperties(handledShape);

View file

@ -687,8 +687,7 @@ public class XmlReader
} else } else
{ {
double arc = getAttrNumValue(seg, "arc", "deg"); double arc = getAttrNumValue(seg, "arc", "deg");
arc = (arc * Math.PI) / 180; ((Curve) shape).setArcDeg(arc);
((Curve) shape).setArc(arc);
double startRad = getAttrNumValue(seg, "radius", "m"); double startRad = getAttrNumValue(seg, "radius", "m");
((Curve) shape).setRadiusStart(startRad); ((Curve) shape).setRadiusStart(startRad);
double endRad = getAttrNumValue(seg, "end radius", "m"); double endRad = getAttrNumValue(seg, "end radius", "m");

View file

@ -284,8 +284,7 @@ public class XmlWriter
addContent(segment, "lg", "m", ((Straight) shape).getLength()); addContent(segment, "lg", "m", ((Straight) shape).getLength());
} else } else
{ {
double arc = ((Curve) shape).getArc(); double arc = ((Curve) shape).getArcDeg();
arc = (arc * 180) / Math.PI;
addContent(segment, "arc", "deg", arc); addContent(segment, "arc", "deg", arc);
double radStart = ((Curve) shape).getRadiusStart(); double radStart = ((Curve) shape).getRadiusStart();

View file

@ -36,7 +36,7 @@ import miscel.EPMath;
public class Curve extends Segment implements Cloneable public class Curve extends Segment implements Cloneable
{ {
protected double arc; protected double arcDeg;
protected double radiusStart; protected double radiusStart;
protected double radiusEnd; protected double radiusEnd;
@ -91,6 +91,7 @@ public class Curve extends Segment implements Cloneable
*/ */
// calc turn length // calc turn length
double arc = arcDeg * Math.PI / 180;
length = arc * (radiusStart + radiusEnd) / 2; length = arc * (radiusStart + radiusEnd) / 2;
nbSteps = (int) (length / profilStepsLength + 0.5) + 1; nbSteps = (int) (length / profilStepsLength + 0.5) + 1;
@ -346,16 +347,30 @@ public class Curve extends Segment implements Cloneable
/** /**
* @return Returns the arc. * @return Returns the arc.
*/ */
public double getArc() public double getArcRad()
{ {
return arc; return arcDeg * Math.PI / 180;
} }
/** /**
* @param arc The arc to set. * @param arc The arc to set.
*/ */
public void setArc(double arc) public void setArcRad(double arcRad)
{ {
this.arc = arc; this.arcDeg = arcRad * 180 / Math.PI;
}
/**
* @return Returns the arc.
*/
public double getArcDeg()
{
return arcDeg;
}
/**
* @param arc The arc to set.
*/
public void setArcDeg(double arcDeg)
{
this.arcDeg = arcDeg;
} }
/** /**
* @return Returns the radiusEnd. * @return Returns the radiusEnd.
@ -401,7 +416,7 @@ public class Curve extends Segment implements Cloneable
{ {
Curve s; Curve s;
s = (Curve) super.clone(); s = (Curve) super.clone();
s.arc = this.arc; s.arcDeg = this.arcDeg;
s.radiusStart = this.radiusStart; s.radiusStart = this.radiusStart;
s.radiusEnd = this.radiusEnd; s.radiusEnd = this.radiusEnd;