[fix][Refactor] rocketcomponent.position.RadiusMethod to be clearer
1. renamed getOuterRadius() => getBoundingRadius() Previous function did not make sense, where implemented in FinSet. 2. Changed implementation of RadiusMethod.*.getRadius() now fails a bit more gracefully.
This commit is contained in:
parent
cfef7532ab
commit
d6f808b376
@ -87,8 +87,8 @@ public abstract class ComponentAssembly extends RocketComponent implements Axia
|
||||
public double getRotationalUnitInertia() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getOuterRadius(){
|
||||
|
||||
public double getBoundingRadius(){
|
||||
double outerRadius=0;
|
||||
for( RocketComponent comp : children ){
|
||||
double thisRadius=0;
|
||||
|
@ -455,10 +455,10 @@ public abstract class FinSet extends ExternalComponent implements RingInstanceab
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOuterRadius(){
|
||||
return 0.0;
|
||||
public double getBoundingRadius(){
|
||||
return 0.;
|
||||
}
|
||||
|
||||
|
||||
private void calculateAreaCG() {
|
||||
Coordinate[] points = this.getFinPoints();
|
||||
finArea = 0;
|
||||
|
@ -34,10 +34,14 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
|
||||
@Override
|
||||
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
||||
if( (parentComponent instanceof BodyTube ) && (thisComponent instanceof RadiusPositionable ) ) {
|
||||
return (((BodyTube)parentComponent).getOuterRadius()+((RadiusPositionable)thisComponent).getOuterRadius() + requestedOffset);
|
||||
double radius = requestedOffset;
|
||||
if( parentComponent instanceof BodyTube ) {
|
||||
radius += ((BodyTube)parentComponent).getOuterRadius();
|
||||
}
|
||||
return requestedOffset; // fail-safe path
|
||||
if( thisComponent instanceof RadiusPositionable ) {
|
||||
radius += ((RadiusPositionable)thisComponent).getBoundingRadius();
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
},
|
||||
|
||||
@ -47,10 +51,14 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
SURFACE ( Application.getTranslator().get("RocketComponent.Position.Method.Radius.SURFACE") ) {
|
||||
@Override
|
||||
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
||||
if( (parentComponent instanceof BodyTube ) && (thisComponent instanceof RadiusPositionable ) ) {
|
||||
return ((BodyTube)parentComponent).getOuterRadius()+((RadiusPositionable)thisComponent).getOuterRadius();
|
||||
double radius = 0.;
|
||||
if( parentComponent instanceof BodyTube ) {
|
||||
radius += ((BodyTube)parentComponent).getOuterRadius();
|
||||
}
|
||||
return 0.; // fail-safe path
|
||||
if( thisComponent instanceof RadiusPositionable ) {
|
||||
radius += ((RadiusPositionable)thisComponent).getBoundingRadius();
|
||||
}
|
||||
return radius;
|
||||
}
|
||||
};
|
||||
|
||||
@ -70,7 +78,7 @@ public enum RadiusMethod implements DistanceMethod {
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean clampToZero() { return true; }
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.sf.openrocket.rocketcomponent.position;
|
||||
|
||||
public interface RadiusPositionable {
|
||||
|
||||
public double getOuterRadius();
|
||||
|
||||
|
||||
public double getBoundingRadius();
|
||||
|
||||
public double getRadiusOffset();
|
||||
public void setRadiusOffset(final double radius);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user