Merge pull request #805 from teyrana/fix/801/launch-lug-radial-position
[fixes #801][fixes #751][fixes #752] Fixes multiple issues with LaunchLug component & ConfigDialog
This commit is contained in:
commit
39c29e8c31
@ -969,16 +969,16 @@ LaunchLugCfg.lbl.Length = Length:
|
||||
LaunchLugCfg.lbl.Outerdiam = Outer diameter:
|
||||
LaunchLugCfg.lbl.Innerdiam = Inner diameter:
|
||||
LaunchLugCfg.lbl.Thickness = Thickness:
|
||||
LaunchLugCfg.lbl.Radialpos = Radial position:
|
||||
LaunchLugCfg.lbl.Angle = Rotation:
|
||||
LaunchLugCfg.lbl.Posrelativeto = Position relative to:
|
||||
LaunchLugCfg.lbl.plus = plus
|
||||
LaunchLugCfg.tab.General = General
|
||||
LaunchLugCfg.tab.Generalprop = General properties
|
||||
|
||||
! LaunchLugConfig
|
||||
! RailButtonConfig
|
||||
RailBtnCfg.lbl.OuterDiam = Outer Diameter:
|
||||
RailBtnCfg.lbl.TotalHeight = Total Height
|
||||
RailBtnCfg.lbl.Angle = Angular Position:
|
||||
RailBtnCfg.lbl.Angle = Rotation:
|
||||
RailBtnCfg.lbl.PosRelativeTo = Position relative to:
|
||||
RailBtnCfg.lbl.Plus = plus
|
||||
RailBtnCfg.tab.General = General
|
||||
|
@ -28,7 +28,6 @@ public class LaunchLugSaver extends ExternalComponentSaver {
|
||||
elements.add("<radius>" + lug.getOuterRadius() + "</radius>");
|
||||
elements.add("<length>" + lug.getLength() + "</length>");
|
||||
elements.add("<thickness>" + lug.getThickness() + "</thickness>");
|
||||
elements.add("<radialdirection>" + (lug.getAngularOffset()*180.0/Math.PI)+ "</radialdirection>");
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,32 +88,31 @@ public class RocketComponentSaver {
|
||||
if ( c instanceof Instanceable) {
|
||||
int instanceCount = c.getInstanceCount();
|
||||
|
||||
if( c instanceof Clusterable ){
|
||||
if (c instanceof Clusterable) {
|
||||
; // no-op. Instance counts are set via named cluster configurations
|
||||
}else {
|
||||
} else {
|
||||
emitInteger(elements, "instancecount", c.getInstanceCount());
|
||||
}
|
||||
|
||||
if( c instanceof LineInstanceable ){
|
||||
LineInstanceable line = (LineInstanceable)c;
|
||||
emitDouble( elements, "instanceseparation", line.getInstanceSeparation());
|
||||
}
|
||||
if( c instanceof RadiusPositionable ){
|
||||
final RadiusPositionable radPos = (RadiusPositionable)c;
|
||||
// The type names are currently equivalent to the enum names except for case.
|
||||
final String radiusMethod = radPos.getRadiusMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
final double radiusOffset = radPos.getRadiusOffset();
|
||||
elements.add("<radiusoffset method=\"" + radiusMethod + "\">" + radiusOffset + "</radiusoffset>");
|
||||
}
|
||||
if( c instanceof AnglePositionable ) {
|
||||
final AnglePositionable anglePos= (AnglePositionable)c;
|
||||
// The type names are currently equivalent to the enum names except for case.
|
||||
final String angleMethod = anglePos.getAngleMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
final double angleOffset = anglePos.getAngleOffset()*180.0/Math.PI ;
|
||||
elements.add("<angleoffset method=\"" + angleMethod + "\">" + angleOffset + "</angleoffset>");
|
||||
|
||||
if (c instanceof LineInstanceable) {
|
||||
LineInstanceable line = (LineInstanceable) c;
|
||||
emitDouble(elements, "instanceseparation", line.getInstanceSeparation());
|
||||
}
|
||||
}
|
||||
if( c instanceof RadiusPositionable ){
|
||||
final RadiusPositionable radPos = (RadiusPositionable)c;
|
||||
// The type names are currently equivalent to the enum names except for case.
|
||||
final String radiusMethod = radPos.getRadiusMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
final double radiusOffset = radPos.getRadiusOffset();
|
||||
elements.add("<radiusoffset method=\"" + radiusMethod + "\">" + radiusOffset + "</radiusoffset>");
|
||||
}
|
||||
if( c instanceof AnglePositionable ) {
|
||||
final AnglePositionable anglePos = (AnglePositionable)c;
|
||||
// The type names are currently equivalent to the enum names except for case.
|
||||
final String angleMethod = anglePos.getAngleMethod().name().toLowerCase(Locale.ENGLISH);
|
||||
final double angleOffset = anglePos.getAngleOffset()*180.0/Math.PI;
|
||||
elements.add("<angleoffset method=\"" + angleMethod + "\">" + angleOffset + "</angleoffset>");
|
||||
}
|
||||
|
||||
// Save position unless "AFTER"
|
||||
if (c.getAxialMethod() != AxialMethod.AFTER) {
|
||||
|
@ -35,7 +35,7 @@ public class LaunchLugDTO extends BasePartDTO {
|
||||
super(theORLaunchLug);
|
||||
setId(theORLaunchLug.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setOd(theORLaunchLug.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
|
||||
setRadialAngle(theORLaunchLug.getAngularOffset());
|
||||
setRadialAngle(theORLaunchLug.getAngleOffset());
|
||||
}
|
||||
|
||||
public double getOd() {
|
||||
|
@ -70,7 +70,7 @@ class LaunchLugHandler extends PositionDependentHandler<LaunchLug> {
|
||||
setMaterialName(content);
|
||||
}
|
||||
if (RocksimCommonConstants.RADIAL_ANGLE.equals(element)) {
|
||||
lug.setAngularOffset(Double.parseDouble(content));
|
||||
lug.setAngleOffset(Double.parseDouble(content));
|
||||
}
|
||||
if (RocksimCommonConstants.FINISH_CODE.equals(element)) {
|
||||
lug.setFinish(RocksimFinishCode.fromCode(Integer.parseInt(content)).asOpenRocket());
|
||||
|
@ -21,14 +21,12 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
private double radius;
|
||||
private double thickness;
|
||||
|
||||
private double radialDirection = 0;
|
||||
private double radialDistance = 0;
|
||||
private double angleOffsetRadians = 0;
|
||||
private double radialOffset = 0;
|
||||
|
||||
private int instanceCount = 1;
|
||||
private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
|
||||
|
||||
private double angle_rad = 0;
|
||||
|
||||
public LaunchLug() {
|
||||
super(AxialMethod.MIDDLE);
|
||||
radius = 0.01 / 2;
|
||||
@ -75,15 +73,17 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
public double getAngularOffset() {
|
||||
return this.radialDirection;
|
||||
@Override
|
||||
public double getAngleOffset() {
|
||||
return this.angleOffsetRadians;
|
||||
}
|
||||
|
||||
public void setAngularOffset(final double newAngle_rad){
|
||||
double clamped_rad = MathUtil.clamp( newAngle_rad, -Math.PI, Math.PI);
|
||||
if (MathUtil.equals(this.radialDirection, clamped_rad))
|
||||
@Override
|
||||
public void setAngleOffset(double newAngleRadians) {
|
||||
double clamped_rad = MathUtil.clamp( newAngleRadians, -Math.PI, Math.PI);
|
||||
if (MathUtil.equals(this.angleOffsetRadians, clamped_rad))
|
||||
return;
|
||||
this.radialDirection = clamped_rad;
|
||||
this.angleOffsetRadians = clamped_rad;
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
@ -94,7 +94,6 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAfter() {
|
||||
return false;
|
||||
@ -126,8 +125,8 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
public Coordinate[] getInstanceOffsets(){
|
||||
Coordinate[] toReturn = new Coordinate[this.getInstanceCount()];
|
||||
|
||||
final double yOffset = Math.cos(radialDirection) * (radialDistance);
|
||||
final double zOffset = Math.sin(radialDirection) * (radialDistance);
|
||||
final double yOffset = Math.cos(angleOffsetRadians) * (radialOffset);
|
||||
final double zOffset = Math.sin(angleOffsetRadians) * (radialOffset);
|
||||
|
||||
for ( int index=0; index < this.getInstanceCount(); index++){
|
||||
toReturn[index] = new Coordinate(index*this.instanceSeparation, yOffset, zOffset);
|
||||
@ -177,12 +176,9 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
parentRadius = Math.max(s.getRadius(x1), s.getRadius(x2));
|
||||
}
|
||||
|
||||
this.radialDistance = parentRadius + radius;
|
||||
this.radialOffset = parentRadius + radius;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public double getComponentVolume() {
|
||||
return length * Math.PI * (MathUtil.pow2(radius) - MathUtil.pow2(radius - thickness));
|
||||
@ -273,18 +269,6 @@ public class LaunchLug extends ExternalComponent implements AnglePositionable, B
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getAngleOffset() {
|
||||
return this.angle_rad;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAngleOffset(double newAngle) {
|
||||
this.angle_rad = newAngle;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AngleMethod getAngleMethod() {
|
||||
return AngleMethod.RELATIVE;
|
||||
|
@ -134,7 +134,7 @@ public class RocksimLoaderTest extends BaseTestCase {
|
||||
|
||||
BodyTube bt = (BodyTube) stage2.getChild(0);
|
||||
LaunchLug ll = (LaunchLug) bt.getChild(6);
|
||||
Assert.assertEquals(1.22d, ll.getAngularOffset(), 0.001);
|
||||
Assert.assertEquals(1.22d, ll.getAngleOffset(), 0.001);
|
||||
|
||||
Assert.assertEquals(2, stage3.getChildCount());
|
||||
Assert.assertEquals("Transition", stage3.getChild(0).getName());
|
||||
|
@ -42,7 +42,7 @@ public class LaunchLugTest extends BaseTestCase {
|
||||
BodyTube body= (BodyTube)rocket.getChild(0).getChild(1);
|
||||
LaunchLug lug = (LaunchLug)rocket.getChild(0).getChild(1).getChild(1);
|
||||
double startAngle = Math.PI/2;
|
||||
lug.setAngularOffset( startAngle );
|
||||
lug.setAngleOffset( startAngle );
|
||||
lug.setInstanceSeparation(0.05);
|
||||
lug.setInstanceCount(2);
|
||||
|
||||
|
@ -92,23 +92,23 @@ public class LaunchLugConfig extends RocketComponentConfig {
|
||||
|
||||
|
||||
//// Radial position:
|
||||
panel.add(new JLabel(trans.get("LaunchLugCfg.lbl.Radialpos")));
|
||||
panel.add(new JLabel(trans.get("LaunchLugCfg.lbl.Angle")));
|
||||
|
||||
m = new DoubleModel(component, "AngularOffset", UnitGroup.UNITS_ANGLE, -180, 180);
|
||||
m = new DoubleModel(component, "AngleOffset", UnitGroup.UNITS_ANGLE, -180, 180);
|
||||
|
||||
spin = new JSpinner(m.getSpinnerModel());
|
||||
spin.setEditor(new SpinnerEditor(spin));
|
||||
panel.add(spin, "growx");
|
||||
|
||||
panel.add(new UnitSelector(m), "growx");
|
||||
panel.add(new BasicSlider(m.getSliderModel(-180, 180) ), "w 100lp, wrap");
|
||||
|
||||
panel.add(new BasicSlider(m.getSliderModel(-Math.PI, Math.PI) ), "w 100lp, wrap");
|
||||
|
||||
// finish up the left column
|
||||
primary.add(panel, "grow, gapright 20lp");
|
||||
|
||||
// create a new panel for the right column
|
||||
panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::][]", ""));
|
||||
|
||||
|
||||
|
||||
//// Position relative to:
|
||||
panel.add(new JLabel(trans.get("LaunchLugCfg.lbl.Posrelativeto")));
|
||||
EnumModel<AxialMethod> positionModel = new EnumModel<AxialMethod>(component, "AxialMethod", AxialMethod.axialOffsetMethods );
|
||||
|
@ -287,7 +287,7 @@ public class FinMarkingGuide extends JPanel {
|
||||
}
|
||||
else if (externalComponent instanceof LaunchLug) {
|
||||
LaunchLug lug = (LaunchLug) externalComponent;
|
||||
double angle = lug.getAngularOffset() - radialOrigin;
|
||||
double angle = lug.getAngleOffset() - radialOrigin;
|
||||
while (angle < 0) {
|
||||
angle += TWO_PI;
|
||||
}
|
||||
@ -331,7 +331,7 @@ public class FinMarkingGuide extends JPanel {
|
||||
for (ExternalComponent component : components) {
|
||||
|
||||
if (component instanceof LaunchLug) {
|
||||
double componentPosition = ((LaunchLug) component).getAngularOffset();
|
||||
double componentPosition = ((LaunchLug) component).getAngleOffset();
|
||||
|
||||
positions.add(makeZeroTwoPi(componentPosition));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user