[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
@ -88,7 +88,7 @@ public abstract class ComponentAssembly extends RocketComponent implements Axia
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOuterRadius(){
|
public double getBoundingRadius(){
|
||||||
double outerRadius=0;
|
double outerRadius=0;
|
||||||
for( RocketComponent comp : children ){
|
for( RocketComponent comp : children ){
|
||||||
double thisRadius=0;
|
double thisRadius=0;
|
||||||
|
@ -455,8 +455,8 @@ public abstract class FinSet extends ExternalComponent implements RingInstanceab
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getOuterRadius(){
|
public double getBoundingRadius(){
|
||||||
return 0.0;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateAreaCG() {
|
private void calculateAreaCG() {
|
||||||
|
@ -34,10 +34,14 @@ public enum RadiusMethod implements DistanceMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
||||||
if( (parentComponent instanceof BodyTube ) && (thisComponent instanceof RadiusPositionable ) ) {
|
double radius = requestedOffset;
|
||||||
return (((BodyTube)parentComponent).getOuterRadius()+((RadiusPositionable)thisComponent).getOuterRadius() + 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") ) {
|
SURFACE ( Application.getTranslator().get("RocketComponent.Position.Method.Radius.SURFACE") ) {
|
||||||
@Override
|
@Override
|
||||||
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
public double getRadius( final RocketComponent parentComponent, final RocketComponent thisComponent, final double requestedOffset ){
|
||||||
if( (parentComponent instanceof BodyTube ) && (thisComponent instanceof RadiusPositionable ) ) {
|
double radius = 0.;
|
||||||
return ((BodyTube)parentComponent).getOuterRadius()+((RadiusPositionable)thisComponent).getOuterRadius();
|
if( parentComponent instanceof BodyTube ) {
|
||||||
|
radius += ((BodyTube)parentComponent).getOuterRadius();
|
||||||
}
|
}
|
||||||
return 0.; // fail-safe path
|
if( thisComponent instanceof RadiusPositionable ) {
|
||||||
|
radius += ((RadiusPositionable)thisComponent).getBoundingRadius();
|
||||||
|
}
|
||||||
|
return radius;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package net.sf.openrocket.rocketcomponent.position;
|
|||||||
|
|
||||||
public interface RadiusPositionable {
|
public interface RadiusPositionable {
|
||||||
|
|
||||||
public double getOuterRadius();
|
public double getBoundingRadius();
|
||||||
|
|
||||||
public double getRadiusOffset();
|
public double getRadiusOffset();
|
||||||
public void setRadiusOffset(final double radius);
|
public void setRadiusOffset(final double radius);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user