1 package net.sf.openrocket.rocketcomponent;
5 * Class to represent a body object. The object can be described as a function of
6 * the cylindrical coordinates x and angle theta as r = f(x,theta). The component
7 * need not be symmetrical in any way (e.g. square tube, slanted cone etc).
9 * It defines the methods getRadius(x,theta) and getInnerRadius(x,theta), as well
12 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
15 public abstract class BodyComponent extends ExternalComponent {
18 * Default constructor. Sets the relative position to POSITION_RELATIVE_AFTER,
19 * i.e. body components come after one another.
21 public BodyComponent() {
22 super(RocketComponent.Position.AFTER);
27 * Get the outer radius of the component at cylindrical coordinate (x,theta).
29 * Note that the return value may be negative for a slanted object.
31 * @param x Distance in x direction
32 * @param theta Angle about the x-axis
33 * @return Distance to the outer edge of the object
35 public abstract double getRadius(double x, double theta);
39 * Get the inner radius of the component at cylindrical coordinate (x,theta).
41 * Note that the return value may be negative for a slanted object.
43 * @param x Distance in x direction
44 * @param theta Angle about the x-axis
45 * @return Distance to the inner edge of the object
47 public abstract double getInnerRadius(double x, double theta);
52 * Sets the length of the body component.
54 public void setLength(double length) {
55 if (this.length == length)
57 this.length = Math.max(length, 0);
58 fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
62 public boolean allowsChildren() {
67 * Accept a visitor to this BodyComponent in the component hierarchy.
69 * @param theVisitor the visitor that will be called back with a reference to this BodyComponent
72 public void accept (final ComponentVisitor theVisitor) {
73 theVisitor.visit(this);