package net.sf.openrocket.rocketcomponent;
+import net.sf.openrocket.util.Coordinate;
+import net.sf.openrocket.util.MathUtil;
+
+import java.util.Collection;
+
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
+import static net.sf.openrocket.util.Chars.FRAC12;
+import static net.sf.openrocket.util.Chars.FRAC34;
import static net.sf.openrocket.util.MathUtil.pow2;
import static net.sf.openrocket.util.MathUtil.pow3;
-import java.util.Collection;
-
-import net.sf.openrocket.util.Coordinate;
-import net.sf.openrocket.util.MathUtil;
-
public class Transition extends SymmetricComponent {
private static final double CLIP_PRECISION = 0.0001;
}
public void setType(Shape type) {
+ if (type == null) {
+ throw new IllegalArgumentException("BUG: setType called with null argument");
+ }
if (this.type == type)
return;
this.type = type;
/**
* Numerically solve clipLength from the equation
* r1 == type.getRadius(clipLength,r2,clipLength+length)
- * using a binary search. It assumes getRadius() to be monotonically increasing.
+ * using a binary search. It assumes getOuterRadius() to be monotonically increasing.
*/
private void calculateClip(double r1, double r2) {
double min=0, max=length;
clipLength = -1;
}
+ /**
+ * Accept a visitor to this Transition in the component hierarchy.
+ *
+ * @param theVisitor the visitor that will be called back with a reference to this Transition
+ */
+ @Override
+ public void accept (final ComponentVisitor theVisitor) {
+ theVisitor.visit(this);
+ }
/**
"<i>Radius</i> × (<i>x</i> / <i>Length</i>)" +
"<sup><i>k</i></sup> "+
"where <i>k</i> is the shape parameter. For <i>k</i>=0.5 this is a "+
- "<b>½-power</b> or <b>parabolic</b> nose cone, for <i>k</i>=0.75 a "+
- "<b>¾-power</b>, and for <i>k</i>=1 a <b>conical</b> nose cone.",
+ "<b>" + FRAC12 +"-power</b> or <b>parabolic</b> nose cone, for <i>k</i>=0.75 a "+
+ "<b>" + FRAC34 +"-power</b>, and for <i>k</i>=1 a <b>conical</b> nose cone.",
"A power series transition has a profile of "+
"<i>Radius</i> × (<i>x</i> / <i>Length</i>)" +
"<sup><i>k</i></sup> "+
"where <i>k</i> is the shape parameter. For <i>k</i>=0.5 the transition is "+
- "<b>½-power</b> or <b>parabolic</b>, for <i>k</i>=0.75 a <b>¾-power</b>, and for " +
- "<i>k</i>=1 <b>conical</b>.",true) {
+ "<b>" + FRAC12 + "-power</b> or <b>parabolic</b>, for <i>k</i>=0.75 a " +
+ "<b>" + FRAC34 + "-power</b>, and for <i>k</i>=1 <b>conical</b>.",true) {
@Override
public boolean usesParameter() { // Range 0...1
return true;