예제 #1
0
  @Override
  public Coordinate[] getLocations() {
    if (null == this.parent) {
      throw new BugException(
          " Attempted to get absolute position Vector of a Stage without a parent. ");
    }

    if (this.isAfter()) {
      return super.getLocations();
    } else {
      Coordinate[] parentInstances = this.parent.getLocations();
      if (1 != parentInstances.length) {
        throw new BugException(
            " OpenRocket does not (yet) support external stages attached to external stages. "
                + "(assumed reason for getting multiple parent locations into an external stage.)");
      }

      final Coordinate center = parentInstances[0].add(this.position);
      Coordinate[] instanceLocations = this.getInstanceOffsets();
      Coordinate[] toReturn = new Coordinate[instanceLocations.length];
      for (int i = 0; i < toReturn.length; i++) {
        toReturn[i] = center.add(instanceLocations[i]);
      }

      return toReturn;
    }
  }
예제 #2
0
  @Override
  public Coordinate[] getInstanceOffsets() {
    checkState();

    final double radius = this.radialPosition_m;
    final double startAngle = this.angularPosition_rad;
    final double angleIncr = this.angularSeparation;
    Coordinate center = Coordinate.ZERO;

    double curAngle = startAngle;
    Coordinate[] toReturn = new Coordinate[this.count];
    for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
      final double curY = radius * Math.cos(curAngle);
      final double curZ = radius * Math.sin(curAngle);
      toReturn[instanceNumber] = center.add(0, curY, curZ);

      curAngle += angleIncr;
    }

    return toReturn;
  }