1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.preset.ComponentPreset;
8 * Class to represent a body object. The object can be described as a function of
9 * the cylindrical coordinates x and angle theta as r = f(x,theta). The component
10 * need not be symmetrical in any way (e.g. square tube, slanted cone etc).
12 * It defines the methods getRadius(x,theta) and getInnerRadius(x,theta), as well
15 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
18 public abstract class BodyComponent extends ExternalComponent {
21 * Default constructor. Sets the relative position to POSITION_RELATIVE_AFTER,
22 * i.e. body components come after one another.
24 public BodyComponent() {
25 super(RocketComponent.Position.AFTER);
30 * Get the outer radius of the component at cylindrical coordinate (x,theta).
32 * Note that the return value may be negative for a slanted object.
34 * @param x Distance in x direction
35 * @param theta Angle about the x-axis
36 * @return Distance to the outer edge of the object
38 public abstract double getRadius(double x, double theta);
42 * Get the inner radius of the component at cylindrical coordinate (x,theta).
44 * Note that the return value may be negative for a slanted object.
46 * @param x Distance in x direction
47 * @param theta Angle about the x-axis
48 * @return Distance to the inner edge of the object
50 public abstract double getInnerRadius(double x, double theta);
54 protected void loadFromPreset(ComponentPreset preset) {
55 super.loadFromPreset(preset);
61 * Sets the length of the body component.
63 * Note: This should be overridden by the subcomponents which need to call
64 * clearPreset(). (BodyTube allows changing length without resetting the preset.)
66 public void setLength(double length) {
67 if (this.length == length)
69 this.length = Math.max(length, 0);
70 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
74 public boolean allowsChildren() {