Merge branch 'unstable' into fix-1210
This commit is contained in:
commit
2aa6a84bf7
@ -885,7 +885,7 @@ RocketCompCfg.checkbox.Overridemass = Override mass:
|
|||||||
RocketCompCfg.checkbox.Overridecenterofgrav = Override center of gravity:
|
RocketCompCfg.checkbox.Overridecenterofgrav = Override center of gravity:
|
||||||
RocketCompCfg.checkbox.SetDragCoeff = Set coefficient of drag:
|
RocketCompCfg.checkbox.SetDragCoeff = Set coefficient of drag:
|
||||||
RocketCompCfg.checkbox.OverridemassandCG = Override mass and CG of all subcomponents
|
RocketCompCfg.checkbox.OverridemassandCG = Override mass and CG of all subcomponents
|
||||||
RocketCompCfg.lbl.longB1 = <html>The overridden mass does not include motors.<br>
|
RocketCompCfg.lbl.longB1 = <html>The overridden mass and center of gravity does not include motors.<br>
|
||||||
RocketCompCfg.lbl.longB2 = The center of gravity is measured from the front end of the
|
RocketCompCfg.lbl.longB2 = The center of gravity is measured from the front end of the
|
||||||
RocketCompCfg.lbl.Commentsonthe = Comments on the
|
RocketCompCfg.lbl.Commentsonthe = Comments on the
|
||||||
RocketCompCfg.lbl.Figurestyle = Figure style:
|
RocketCompCfg.lbl.Figurestyle = Figure style:
|
||||||
|
@ -852,8 +852,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
|||||||
private void buildCalcMap(FlightConfiguration configuration) {
|
private void buildCalcMap(FlightConfiguration configuration) {
|
||||||
calcMap = new HashMap<>();
|
calcMap = new HashMap<>();
|
||||||
|
|
||||||
// because this is not a per-instance iteration... this usage of 'getActiveComponents' is probably fine.
|
for (RocketComponent comp: configuration.getAllComponents()) {
|
||||||
for (RocketComponent comp: configuration.getActiveComponents()) {
|
|
||||||
if (!comp.isAerodynamic())
|
if (!comp.isAerodynamic())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ package net.sf.openrocket.file.rocksim.importt;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
@ -359,17 +360,25 @@ class FinSetHandler extends AbstractElementHandler {
|
|||||||
* @return an array of OpenRocket Coordinates
|
* @return an array of OpenRocket Coordinates
|
||||||
*/
|
*/
|
||||||
private Coordinate[] toCoordinates(String newPointList, WarningSet warnings) {
|
private Coordinate[] toCoordinates(String newPointList, WarningSet warnings) {
|
||||||
List<Coordinate> result = new ArrayList<Coordinate>();
|
List<Coordinate> result = new LinkedList<>();
|
||||||
if (newPointList != null && newPointList.length() > 0) {
|
if (newPointList != null && newPointList.length() > 0) {
|
||||||
String[] points = newPointList.split("\\Q|\\E");
|
String[] points = newPointList.split("\\Q|\\E");
|
||||||
for (String point : points) {
|
for (int i = 0; i < points.length; i++) {
|
||||||
String[] aPoint = point.split(",");
|
String[] aPoint = points[i].split(",");
|
||||||
try {
|
try {
|
||||||
if (aPoint.length > 1) {
|
if (aPoint.length > 1) {
|
||||||
Coordinate c = new Coordinate(
|
Coordinate c = new Coordinate(
|
||||||
Double.parseDouble(aPoint[0]) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH,
|
Double.parseDouble(aPoint[0]) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH,
|
||||||
Double.parseDouble(aPoint[1]) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
Double.parseDouble(aPoint[1]) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
result.add(c);
|
if (result.size() == 0) {
|
||||||
|
result.add(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Coordinate lastCoord = result.get(result.size() - 1);
|
||||||
|
// RockSim sometimes saves a multitude of '0,0' coordinates, so ignore this
|
||||||
|
if (! ((lastCoord.x == 0) && (lastCoord.y == 0) && (c.x == 0) && (c.y == 0))) {
|
||||||
|
result.add(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
warnings.add("Invalid fin point pair.");
|
warnings.add("Invalid fin point pair.");
|
||||||
|
@ -72,6 +72,10 @@ public class MassCalculation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addMass(double mass) {
|
||||||
|
this.centerOfMass = this.centerOfMass.setWeight(getMass() + mass);
|
||||||
|
}
|
||||||
|
|
||||||
public MassCalculation copy( final RocketComponent _root, final Transformation _transform){
|
public MassCalculation copy( final RocketComponent _root, final Transformation _transform){
|
||||||
return new MassCalculation( this.type, this.config, this.simulationTime, this.activeMotorList, _root, _transform, this.analysisMap);
|
return new MassCalculation( this.type, this.config, this.simulationTime, this.activeMotorList, _root, _transform, this.analysisMap);
|
||||||
}
|
}
|
||||||
@ -84,6 +88,10 @@ public class MassCalculation {
|
|||||||
return this.centerOfMass.weight;
|
return this.centerOfMass.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMass(double mass) {
|
||||||
|
this.centerOfMass = this.centerOfMass.setWeight(mass);
|
||||||
|
}
|
||||||
|
|
||||||
public double getLongitudinalInertia() {
|
public double getLongitudinalInertia() {
|
||||||
return this.inertia.Iyy;
|
return this.inertia.Iyy;
|
||||||
}
|
}
|
||||||
@ -449,6 +457,7 @@ public class MassCalculation {
|
|||||||
//System.err.println(String.format( "%s....assembly mass (incl/children): %s", prefix, this.toCMDebug()));
|
//System.err.println(String.format( "%s....assembly mass (incl/children): %s", prefix, this.toCMDebug()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // vvv DEBUG
|
// // vvv DEBUG
|
||||||
// if( this.config.isComponentActive(component) && 0 < this.getMass() ) {
|
// if( this.config.isComponentActive(component) && 0 < this.getMass() ) {
|
||||||
// System.err.println(String.format( "%s....<< return assemblyData: %s (tree @%s)", prefix, this.toCMDebug(), component.getName() ));
|
// System.err.println(String.format( "%s....<< return assemblyData: %s (tree @%s)", prefix, this.toCMDebug(), component.getName() ));
|
||||||
|
@ -76,6 +76,11 @@ public class RigidBody {
|
|||||||
MathUtil.equals(this.Izz, other.Izz)) ;
|
MathUtil.equals(this.Izz, other.Izz)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebase the current moment of inertia from this.cm reference system to newLocation reference system
|
||||||
|
* @param newLocation new moment of inertia reference system
|
||||||
|
* @return RigidBody with rebased moment of inertia
|
||||||
|
*/
|
||||||
public RigidBody rebase( final Coordinate newLocation ){
|
public RigidBody rebase( final Coordinate newLocation ){
|
||||||
final Coordinate delta = this.cm.sub( newLocation ).setWeight(0.);
|
final Coordinate delta = this.cm.sub( newLocation ).setWeight(0.);
|
||||||
double x2 = pow2(delta.x);
|
double x2 = pow2(delta.x);
|
||||||
|
@ -1624,6 +1624,23 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the parent and super-parent components of this component.
|
||||||
|
* @return parent and super-parents of this component
|
||||||
|
*/
|
||||||
|
public final List<RocketComponent> getParents() {
|
||||||
|
checkState();
|
||||||
|
List<RocketComponent> result = new LinkedList<>();
|
||||||
|
RocketComponent currComp = this;
|
||||||
|
|
||||||
|
while (currComp.parent != null) {
|
||||||
|
currComp = currComp.parent;
|
||||||
|
result.add(currComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the root component of the component tree.
|
* Get the root component of the component tree.
|
||||||
*
|
*
|
||||||
@ -1711,6 +1728,26 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all the component assemblies that are a parent or super-parent of this component
|
||||||
|
* @return list of ComponentAssembly components that are a parent or super-parent of this component
|
||||||
|
*/
|
||||||
|
public final List<RocketComponent> getParentAssemblies() {
|
||||||
|
checkState();
|
||||||
|
|
||||||
|
List<RocketComponent> result = new LinkedList<>();
|
||||||
|
RocketComponent currComp = this;
|
||||||
|
|
||||||
|
while (currComp.parent != null) {
|
||||||
|
currComp = currComp.parent;
|
||||||
|
if (currComp instanceof ComponentAssembly) {
|
||||||
|
result.add(currComp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the stage number of the stage this component belongs to. The stages
|
* Return the stage number of the stage this component belongs to. The stages
|
||||||
|
@ -6,7 +6,6 @@ import java.awt.Container;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -339,16 +338,31 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
m = new DoubleModel(component, "OverrideCGX", UnitGroup.UNITS_LENGTH, 0);
|
m = new DoubleModel(component, "OverrideCGX", UnitGroup.UNITS_LENGTH, 0);
|
||||||
// Calculate suitable length for slider
|
// Calculate suitable length for slider
|
||||||
DoubleModel length;
|
DoubleModel length;
|
||||||
if (component instanceof ComponentAssembly) {
|
if (component.getChildCount() > 0) {
|
||||||
double l = 0;
|
Iterator<RocketComponent> iterator = component.iterator(true);
|
||||||
|
double minL = Double.MAX_VALUE;
|
||||||
|
double maxL = Double.MIN_VALUE;
|
||||||
|
|
||||||
Iterator<RocketComponent> iterator = component.iterator(false);
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
RocketComponent c = iterator.next();
|
RocketComponent c = iterator.next();
|
||||||
if (c.getAxialMethod() == AxialMethod.AFTER)
|
|
||||||
l += c.getLength();
|
double compPos = c.getAxialOffset(AxialMethod.ABSOLUTE);
|
||||||
|
if (compPos < minL) {
|
||||||
|
minL = compPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
double compLen = c.getLength();
|
||||||
|
if (c instanceof FinSet) {
|
||||||
|
compLen = ((FinSet) c).getInstanceBoundingBox().span().x;
|
||||||
|
}
|
||||||
|
if (compPos + compLen > maxL) {
|
||||||
|
maxL = compPos + compLen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
length = new DoubleModel(l);
|
length = new DoubleModel(maxL - minL);
|
||||||
|
} else if (component instanceof FinSet) {
|
||||||
|
double compLen = ((FinSet) component).getInstanceBoundingBox().span().x;
|
||||||
|
length = new DoubleModel(compLen);
|
||||||
} else {
|
} else {
|
||||||
length = new DoubleModel(component, "Length", UnitGroup.UNITS_LENGTH, 0);
|
length = new DoubleModel(component, "Length", UnitGroup.UNITS_LENGTH, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user