[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
core/src/net/sf/openrocket/rocketcomponent
@ -87,8 +87,8 @@ public abstract class ComponentAssembly extends RocketComponent implements Axia
|
|||||||
public double getRotationalUnitInertia() {
|
public double getRotationalUnitInertia() {
|
||||||
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,10 +455,10 @@ 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() {
|
||||||
Coordinate[] points = this.getFinPoints();
|
Coordinate[] points = this.getFinPoints();
|
||||||
finArea = 0;
|
finArea = 0;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,7 +78,7 @@ public enum RadiusMethod implements DistanceMethod {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean clampToZero() { return true; }
|
public boolean clampToZero() { return true; }
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package net.sf.openrocket.rocketcomponent.position;
|
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