/** * Create a new motor instance configuration for the rocket configuration. * * @param configuration the rocket configuration. * @return a new motor instance configuration with all motors in place. */ private MotorInstanceConfiguration setupMotorConfiguration(Configuration configuration) { MotorInstanceConfiguration motors = new MotorInstanceConfiguration(); final String motorId = configuration.getMotorConfigurationID(); Iterator<MotorMount> iterator = configuration.motorIterator(); while (iterator.hasNext()) { MotorMount mount = iterator.next(); RocketComponent component = (RocketComponent) mount; Motor motor = mount.getMotor(motorId); if (motor != null) { Coordinate[] positions = component.toAbsolute(mount.getMotorPosition(motorId)); for (int i = 0; i < positions.length; i++) { Coordinate position = positions[i]; MotorId id = new MotorId(component.getID(), i + 1); motors.addMotor(id, motor.getInstance(), mount, position); } } } return motors; }