예제 #1
2
void generate_stellar_system()
{
     planet_pointer planet;
     radians_per_rotation = 2.0 * PI;
     stellar_mass_ratio = random_number(0.6,1.3);
     stellar_luminosity_ratio = luminosity(stellar_mass_ratio);
     planet = distribute_planetary_masses(stellar_mass_ratio,stellar_luminosity_ratio,0.0,stellar_dust_limit(stellar_mass_ratio));
     main_seq_life = 1.0E10 * (stellar_mass_ratio / stellar_luminosity_ratio);
     if ((main_seq_life >= 6.0E9))
	  age = random_number(1.0E9,6.0E9);
     else
	  age = random_number(1.0E9,main_seq_life);
     r_ecosphere = sqrt(stellar_luminosity_ratio);
     r_greenhouse = r_ecosphere * GREENHOUSE_EFFECT_CONST;
     while (planet != NULL)
     {
	  planet->orbit_zone = orbital_zone(planet->a);
	  if (planet->gas_giant)
	  {
	       planet->density = empirical_density(planet->mass,planet->a,planet->gas_giant);
	       planet->radius = volume_radius(planet->mass,planet->density);
	  }
	  else
	  {
	       planet->radius = kothari_radius(planet->mass,planet->a,planet->gas_giant,planet->orbit_zone);
	       planet->density = volume_density(planet->mass,planet->radius);
	  }
	  planet->orbital_period = period(planet->a,planet->mass,stellar_mass_ratio);
	  planet->day = day_length(planet->mass,planet->radius,planet->orbital_period,planet->e,planet->gas_giant);
	  planet->resonant_period = spin_resonance;
	  planet->axial_tilt = inclination(planet->a);
	  planet->escape_velocity = escape_vel(planet->mass,planet->radius);
	  planet->surface_accel = acceleration(planet->mass,planet->radius);
	  planet->rms_velocity = rms_vel(MOLECULAR_NITROGEN,planet->a);
	  planet->molecule_weight = molecule_limit(planet->a,planet->mass,planet->radius);
	  if ((planet->gas_giant))
	  {
	       planet->surface_grav = INCREDIBLY_LARGE_NUMBER;
	       planet->greenhouse_effect = FALSE;
	       planet->volatile_gas_inventory = INCREDIBLY_LARGE_NUMBER;
	       planet->surface_pressure = INCREDIBLY_LARGE_NUMBER;
	       planet->boil_point = INCREDIBLY_LARGE_NUMBER;
	       planet->hydrosphere = INCREDIBLY_LARGE_NUMBER;
	       planet->albedo = about(GAS_GIANT_ALBEDO,0.1);
	       planet->surface_temp = INCREDIBLY_LARGE_NUMBER;
	  }
	  else
	  {
	       planet->surface_grav = gravity(planet->surface_accel);
	       planet->greenhouse_effect = greenhouse(planet->orbit_zone,planet->a,r_greenhouse);
	       planet->volatile_gas_inventory = vol_inventory(planet->mass,planet->escape_velocity,planet->rms_velocity,stellar_mass_ratio,planet->orbit_zone,planet->greenhouse_effect);
	       planet->surface_pressure = pressure(planet->volatile_gas_inventory,planet->radius,planet->surface_grav);
	       if ((planet->surface_pressure == 0.0))
		    planet->boil_point = 0.0;
	       else
		    planet->boil_point = boiling_point(planet->surface_pressure);
	       iterate_surface_temp(&(planet));
	  }
	  planet = planet->next_planet;
     }
     display_system( );
}
예제 #2
0
        void body_rotator::calc_orientation_aux(double alpha, double delta, double W, transform & orientation)
        {
            // convert angles to radians
            alpha *= math::DEG2RAD;
            delta *= math::DEG2RAD;
            W *= math::DEG2RAD;

            // calculate orientation
            gsgl::real_t rot_angle = static_cast<gsgl::real_t>(PI_OVER_2 + alpha + W);
            quaternion rotation(vector::Z_AXIS, rot_angle);

            gsgl::real_t inc_angle = static_cast<gsgl::real_t>( PI_OVER_2 - delta );

            double axis_angle = PI_OVER_2 + alpha;
            gsgl::real_t axis_x = static_cast<gsgl::real_t>( ::cos(axis_angle) );
            gsgl::real_t axis_y = static_cast<gsgl::real_t>( ::sin(axis_angle) );

            quaternion inclination(vector(axis_x, axis_y, 0), inc_angle);
            quaternion oq = inclination * rotation;

            orientation = EQUATORIAL_WRT_ECLIPTIC * transform(oq);
        } // body_rotator::calc_orientation_aux()
예제 #3
0
void MainWindow::initializeQMLComponent()
{
    QDeclarativeContext *context = m_view->rootContext();

#if defined(Q_WS_MAEMO_5) || defined(QT_NO_OPENGL)
    // Set UI to low performance mode for Maemo5 and Symbian^1. This mainly
    // disables antialiasing on some performance costly elements.
    context->setContextProperty("lowPerf", true);
#else
    context->setContextProperty("lowPerf", false);
#endif

#ifdef Q_OS_SYMBIAN
    context->setContextProperty("sampleFolder", "file:");
#else
    context->setContextProperty("sampleFolder", QString("file:/") +
                                QDir::currentPath());
#endif

#ifdef Q_WS_MAEMO_6
    // Hide the exit button in Harmattan
    context->setContextProperty("exitButtonVisible", false);
#else
    context->setContextProperty("exitButtonVisible", true);
#endif

    m_view->setSource(QUrl("qrc:/qml/Main.qml"));

    // Create Qt settings object to load / store app settings
    m_settings = new QSettings("Nokia", "DJTurntable");

    // Create Qt objects to handle Turntable and Drum machine
    m_turntable = new Turntable(m_settings, this);
    m_drumMachine = new DrumMachine(m_settings, this);
    m_turntable->addAudioSource(m_drumMachine);

    // Find out the interesting Qt objects of the QML elements
    QObject *turntableQML = dynamic_cast<QObject*>(m_view->rootObject());
    QObject *sampleSelectorQML =
            m_view->rootObject()->findChild<QObject*>("sampleSelector");
    QObject *drumMachineQML =
            m_view->rootObject()->findChild<QObject*>("drumMachine");

    // If there are errors in QML code and the elements does not exist,
    // they won't be found Qt side either, check existance of the elements.
    if (!turntableQML || !sampleSelectorQML || !drumMachineQML) {
        QMessageBox::warning(NULL, "Warning",
                             "Failed to resolve QML elements in main.cpp");
        return;
    }

    // Turntable connections
    connect(turntableQML, SIGNAL(start()),
            m_turntable, SLOT(start()));
    connect(turntableQML, SIGNAL(stop()),
            m_turntable, SLOT(stop()));
    connect(turntableQML, SIGNAL(diskAimSpeed(QVariant)),
            m_turntable, SLOT(setDiscAimSpeed(QVariant)));
    connect(turntableQML, SIGNAL(diskSpeed(QVariant)),
            m_turntable, SLOT(setDiscSpeed(QVariant)));
    connect(turntableQML, SIGNAL(cutOff(QVariant)),
            m_turntable, SLOT(setCutOff(QVariant)));
    connect(turntableQML, SIGNAL(resonance(QVariant)),
            m_turntable, SLOT(setResonance(QVariant)));
    connect(turntableQML, SIGNAL(seekToPosition(QVariant)),
            m_turntable, SLOT(seekToPosition(QVariant)));
    connect(m_turntable, SIGNAL(audioPosition(QVariant)),
            turntableQML, SLOT(audioPosition(QVariant)));
    connect(m_turntable, SIGNAL(powerOff()),
            turntableQML, SLOT(powerOff()));

    // SampleSelector connections
    connect(sampleSelectorQML, SIGNAL(sampleSelected(QVariant)),
            m_turntable, SLOT(setSample(QVariant)));
    connect(sampleSelectorQML, SIGNAL(defaultSample()),
            m_turntable, SLOT(openDefaultSample()));
    connect(m_turntable, SIGNAL(sampleOpened(QVariant)),
            sampleSelectorQML, SLOT(setCurrentSample(QVariant)));
    connect(m_turntable, SIGNAL(error(QVariant, QVariant)),
            sampleSelectorQML, SLOT(showError(QVariant, QVariant)));

    // DrumMachine connections
    connect(drumMachineQML, SIGNAL(startBeat()),
            m_drumMachine, SLOT(startBeat()));
    connect(drumMachineQML, SIGNAL(stopBeat()),
            m_drumMachine, SLOT(stopBeat()));
    connect(drumMachineQML, SIGNAL(setBeat(QVariant)),
            m_drumMachine, SLOT(setBeat(QVariant)));
    connect(drumMachineQML,
            SIGNAL(drumButtonToggled(QVariant, QVariant, QVariant)),
            m_drumMachine,
            SLOT(drumButtonToggled(QVariant, QVariant, QVariant)));
    connect(drumMachineQML, SIGNAL(drumMachineSpeed(QVariant)),
            m_drumMachine, SLOT(setBeatSpeed(QVariant)));
    connect(m_drumMachine,
            SIGNAL(drumButtonState(QVariant, QVariant, QVariant)),
            drumMachineQML,
            SLOT(setDrumButton(QVariant, QVariant, QVariant)));
    connect(m_drumMachine, SIGNAL(tickChanged(QVariant)),
            drumMachineQML, SLOT(highlightTick(QVariant)));

    // Framework connections
    connect((QObject*)m_view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
#ifndef QT_NO_OPENGL
    // Create Qt accelerometer objects
    m_accelerometer = new QAccelerometer(this);
    m_accelerometerFilter = new AccelerometerFilter;
    // Does not take the ownership of the filter
    m_accelerometer->addFilter(m_accelerometerFilter);

    m_accelerometer->setDataRate(50);

    // Create Qt objects for accessing profile information
    m_deviceInfo = new QSystemDeviceInfo(this);
    m_turntable->profile(m_deviceInfo->currentProfile());

    connect(m_accelerometerFilter, SIGNAL(rotationChanged(QVariant)),
            turntableQML, SLOT(inclination(QVariant)));
    connect(m_deviceInfo,
            SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
            m_turntable,
            SLOT(profile(QSystemDeviceInfo::Profile)));

    // Begin the measuring of the accelerometer sensor
    m_accelerometer->start();
#endif
#endif

    m_turntable->openLastSample();
    m_drumMachine->setBeat(0);
}
예제 #4
0
stellar_system* generate_stellar_system(unsigned long random_seed)
{
  planet* planet;
  double      outer_dust_limit;

  stellar_system *system = malloc(sizeof(stellar_system));
  system->first_planet = NULL;
  setup_seed(system, random_seed);

  system->star_mass_r = random_number(0.6, 1.3);  /* was 0.6, 1.3 */
  system->star_radius_r = about(pow(system->star_mass_r, 1.0 / 3.0), 0.05);
  /* for some unknown reason, only 3 digits wanted... */
  system->star_radius_r = floor(system->star_radius_r * 1000.0) / 1000.0;
  system->star_lum_r = luminosity(system->star_mass_r);
  /* luminosity is proportional to T^4 and to area of star */
  /* so temp is Tsol * 4th-root ( Lum / r^2 )              */
  system->star_temp = 5650 * sqrt(sqrt(system->star_lum_r) / system->star_radius_r);
  /* ignore fractional degrees */
  system->star_temp = floor(system->star_temp);
  sprintf(system->star_class, "%.16s", find_star_class(system->star_temp));
  outer_dust_limit = stellar_dust_limit(system->star_mass_r);
  system->first_planet = distribute_planetary_masses(system, 0.0, outer_dust_limit);
  system->main_seq_life = 1.0E10 * (system->star_mass_r / system->star_lum_r);
  if (system->main_seq_life > 6.0E9)
    system->star_age = random_number(1.0E9, 6.0E9);
  else if (system->main_seq_life > 1.0E9)
    system->star_age = random_number(1.0E9, system->main_seq_life);
  else
    system->star_age = random_number(system->main_seq_life/10, system->main_seq_life);
  system->r_ecosphere = sqrt(system->star_lum_r);
  system->r_greenhouse = system->r_ecosphere * GREENHOUSE_EFFECT_CONST;
  for (planet = system->first_planet; planet != NULL; planet = planet->next_planet)
  {
    planet->orbit_zone = orbital_zone(system, planet->a);
    if (planet->gas_giant)
    {
      planet->density = empirical_density(system, planet->mass, planet->a, 
                                          planet->gas_giant);
      planet->radius = volume_radius(planet->mass, planet->density);
    }
    else
    {
      planet->radius = kothari_radius(planet->mass, planet->gas_giant, 
                                      planet->orbit_zone);
      planet->density = volume_density(planet->mass, planet->radius);
    }
    planet->orb_period = period(planet->a, planet->mass, system->star_mass_r);
    planet->day = day_length(system, planet->mass, planet->radius, planet->e,
           planet->density, planet->a,
           planet->orb_period, planet->gas_giant,
           system->star_mass_r);
    planet->resonant_period = system->resonance;
    planet->axial_tilt = inclination(planet->a);
    planet->esc_velocity = escape_velocity(planet->mass, planet->radius);
    planet->surf_accel = acceleration(planet->mass, planet->radius);
    planet->rms_velocity = rms_velocity(system, MOL_NITROGEN, planet->a);
    planet->molec_weight = molecule_limit(planet->mass, planet->radius);
    if ((planet->gas_giant))
    {
      planet->surf_grav = INCREDIBLY_LARGE_NUMBER;
      planet->greenhouse_effect = false;
      planet->volatile_gas_inventory = INCREDIBLY_LARGE_NUMBER;
      planet->surf_pressure = INCREDIBLY_LARGE_NUMBER;
      planet->boil_point = INCREDIBLY_LARGE_NUMBER;
      planet->hydrosphere = INCREDIBLY_LARGE_NUMBER;
      planet->albedo = about(GAS_GIANT_ALBEDO, 0.1);
      planet->surf_temp = INCREDIBLY_LARGE_NUMBER;
    }
    else
    {
      planet->surf_grav = gravity(planet->surf_accel);
      planet->greenhouse_effect = greenhouse(planet->orbit_zone, planet->a, 
                                           system->r_greenhouse);
      planet->volatile_gas_inventory = vol_inventory(planet->mass, 
                                                     planet->esc_velocity, 
                                                     planet->rms_velocity, 
                                                     system->star_mass_r, 
                                                     planet->orbit_zone, 
                                                     planet->greenhouse_effect);
      planet->surf_pressure = pressure(planet->volatile_gas_inventory, 
                                       planet->radius, planet->surf_grav);
      if (planet->surf_pressure == 0.0)
        planet->boil_point = 0.0;
      else
        planet->boil_point = boiling_point(planet->surf_pressure);
      iterate_surface_temp(system, &(planet));
    }
#ifdef  MOON
    if (args.make_moon)
    {
#ifdef  PROPER_MOON
      planet->first_moon = dist_moon_masses(planet->mass,
              star_lum_r, planet->e,
              0.0, planet_dust_limit(planet->mass));
#else
      planet->first_moon = do_dist_moon_masses(planet->mass, planet->radius);
      {
  planet* moon = planet->first_moon;

  while (moon)
  {
    moon->radius = kothari_radius(moon->mass, 0, planet->orbit_zone);
    moon->density = volume_density(moon->mass, moon->radius);
    moon->density = random_number(1.5, moon->density * 1.1);
    if (moon->density < 1.5)
      moon->density = 1.5;
    moon->radius = volume_radius(moon->mass, moon->density);
    moon->orb_period = period(moon->a, moon->mass, planet->mass);
    moon->day = day_length(system, moon->mass, moon->radius, moon->e,
         moon->density, moon->a,
         moon->orb_period, moon->gas_giant,
         planet->mass);
    moon->resonant_period = system->resonance;
    moon->axial_tilt = inclination(moon->a);
    moon->esc_velocity = escape_vel(moon->mass, moon->radius);
    moon->surf_accel = acceleration(moon->mass, moon->radius);
    moon->rms_velocity = rms_vel(system, MOL_NITROGEN, planet->a);
    moon->molec_weight = molecule_limit(moon->mass, moon->radius);
    moon->surf_grav = gravity(moon->surf_accel);
    moon->greenhouse_effect = grnhouse(planet->orbit_zone,
               planet->a,
               system->r_greenhouse);
    moon->volatile_gas_inventory = vol_inventory(moon->mass,
                   moon->esc_velocity,
                   moon->rms_velocity,
                   system->star_mass_r,
                   planet->orbit_zone,
              moon->greenhouse_effect);
    moon->surf_pressure = pressure(moon->volatile_gas_inventory,
           moon->radius, moon->surf_grav);
    if ((moon->surf_pressure == 0.0))
      moon->boil_point = 0.0;
    else
      moon->boil_point = boiling_point(moon->surf_pressure);
    iterate_surface_temp_moon(system, &planet, &moon);
    moon = moon->next_planet;
  }
      }
#endif        /* CC_MOON */
    }
#endif        /* MOON */
  }
  return system;
}