本文整理汇总了C++中SolarSystem类的典型用法代码示例。如果您正苦于以下问题:C++ SolarSystem类的具体用法?C++ SolarSystem怎么用?C++ SolarSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SolarSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSolarSystems
void Galaxy::setSolarSystems(QList<SolarSystem> solarSystems) {
data->solarSystems.clear();
for (int i = 0; i < solarSystems.size(); i++) {
SolarSystem solarSystem = solarSystems.at(i);
data->solarSystems.insert(solarSystem.getName(), solarSystem);
}
}
示例2: GETSTELMODULE
////////////////////////////////////////////////////////////////////////////////
// Increment time
void StelCore::updateTime(double deltaTime)
{
JDay+=timeSpeed*deltaTime;
// Fix time limits to -100000 to +100000 to prevent bugs
if (JDay>38245309.499988) JDay = 38245309.499988;
if (JDay<-34803211.500012) JDay = -34803211.500012;
if (position->isObserverLifeOver())
{
// Unselect if the new home planet is the previously selected object
StelObjectMgr* objmgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(objmgr);
if (objmgr->getWasSelected() && objmgr->getSelectedObject()[0].data()==position->getHomePlanet())
{
objmgr->unSelect();
}
StelObserver* newObs = position->getNextObserver();
delete position;
position = newObs;
}
position->update(deltaTime);
// Position of sun and all the satellites (ie planets)
SolarSystem* solsystem = (SolarSystem*)StelApp::getInstance().getModuleMgr().getModule("SolarSystem");
solsystem->computePositions(getJDay(), position->getHomePlanet()->getHeliocentricEclipticPos());
}
示例3: setSelection
// Choose a planet around a star given it's index in the planetary system.
// The planetary system is either the system of the selected object, or the
// nearest planetary system if no object is selected. If index is less than
// zero, pick the star. This function should probably be in celestiacore.cpp.
void Simulation::selectPlanet(int index)
{
if (index < 0)
{
if (selection.getType() == Selection::Type_Body)
{
PlanetarySystem* system = selection.body()->getSystem();
if (system != NULL)
setSelection(system->getStar());
}
}
else
{
const Star* star = NULL;
if (selection.getType() == Selection::Type_Star)
star = selection.star();
else if (selection.getType() == Selection::Type_Body)
star = getSun(selection.body());
SolarSystem* solarSystem = NULL;
if (star != NULL)
solarSystem = universe->getSolarSystem(star);
else
solarSystem = closestSolarSystem;
if (solarSystem != NULL &&
index < solarSystem->getPlanets()->getSystemSize())
{
setSelection(Selection(solarSystem->getPlanets()->getBody(index)));
}
}
}
示例4: QPixmap
// Update the map for the given location.
void LocationDialog::setMapForLocation(const StelLocation& loc)
{
// Avoids useless processing
if (lastPlanet==loc.planetName)
return;
QPixmap pixmap;
// Try to set the proper planet map image
if (loc.planetName=="Earth")
{
// Special case for earth, we don't want to see the clouds
pixmap = QPixmap(":/graphicGui/world.png");
}
else
{
SolarSystem* ssm = GETSTELMODULE(SolarSystem);
PlanetP p = ssm->searchByEnglishName(loc.planetName);
if (p)
{
QString path = StelFileMgr::findFile("textures/"+p->getTextMapName());
if (path.isEmpty())
{
qWarning() << "ERROR - could not find planet map for " << loc.planetName;
return;
}
pixmap = QPixmap(path);
}
}
ui->mapLabel->setPixmap(pixmap);
// For caching
lastPlanet = loc.planetName;
}
示例5: main
/**************************************************************************//**
* @author Johnny Ackerman, Danial Andrus
*
* @par Description:
* Main function of the program. Passes control to the SolarSystem Class
*
*
* @param[in] argc - Number of aurments from the command line
* @param[out] argv - An array of command line aurgments
*
* @returns 0 - program ran successfully.
*****************************************************************************/
int main( int argc, char *argv[] )
{
// Initialize program's core class
SolarSystem solarsystem;
// Run everything through the Fractals class
return solarsystem.run( argc, argv);
}
示例6: SatelliteAttitude
// -----------------------------------------------------------------------------------
// Version with JPL SolarSystem ephemeris. Throw if the SolarSystem is not valid
Matrix<double> SatelliteAttitude(const CommonTime& tt, const Position& SV,
const SolarSystem& SSEph, const EarthOrientation& EO,
double& sf)
throw(Exception)
{
if(SSEph.JPLNumber() == -1 || SSEph.startTime()-tt > 1.e-8
|| tt - SSEph.endTime() > 1.e-8) {
Exception e("Solar system ephemeris invalid");
GPSTK_THROW(e);
}
return doSatAtt(tt,SV,SSEph,EO,sf);
}
示例7: Java_com_example_Gravity_Gravity_getGravityObjectName
/*******************************************************************************
*
* FUNCTION NAME: getGravityObjectName
*
*------------------------ DETAILED FUNCTION DESCRIPTION ------------------------
*
* Gets the name text for the object from the gravity system.
*
*******************************************************************************/
JNIEXPORT jstring Java_com_example_Gravity_Gravity_getGravityObjectName( JNIEnv* env, jobject obj, jint index )
{
char * nameText = (char*)"Unknown";
uint32_t textLength;
uint32_t numObjects = mySolarSystem.getNumObjects();
if ( ( index < numObjects ) && ( index >= 0 ) )
{
mySolarSystem.getGravityObjectInfo( index, &nameText, &textLength );
}
return env->NewStringUTF(nameText);
}
示例8:
void RK4::integrate(std::valarray<double> &X, std::valarray<double> &V, double dt, SolarSystem mysystem, double G, double eps)
{
std::valarray<double> k1(1,6*mysystem.numberOfBodies());
std::valarray<double> k2(1,6*mysystem.numberOfBodies());
std::valarray<double> k3(1,6*mysystem.numberOfBodies());
std::valarray<double> k4(1,6*mysystem.numberOfBodies());
// RK4 integration using vector X from solarysystem class.
k1 = mysystem.calculateRK4(X, V, G, eps) * dt;
k2 = mysystem.calculateRK4(X + 0.5 * k1, V, G, eps) * dt;
k3 = mysystem.calculateRK4(X + 0.5 * k2, V, G, eps) * dt;
k4 = mysystem.calculateRK4(X + k3, V, G, eps) * dt;
X += (1.0/6) * (k1 + 2 * (k2 + k3) + k4);
}
示例9: disconnectEditSignals
void LocationDialog::setFieldsFromLocation(const StelLocation& loc)
{
// Deactivate edit signals
disconnectEditSignals();
ui->cityNameLineEdit->setText(loc.name);
int idx = ui->countryNameComboBox->findData(loc.country, Qt::UserRole, Qt::MatchCaseSensitive);
if (idx==-1)
{
// Use France as default
ui->countryNameComboBox->findData(QVariant("France"), Qt::UserRole, Qt::MatchCaseSensitive);
}
ui->countryNameComboBox->setCurrentIndex(idx);
ui->longitudeSpinBox->setDegrees(loc.longitude);
ui->latitudeSpinBox->setDegrees(loc.latitude);
ui->altitudeSpinBox->setValue(loc.altitude);
idx = ui->planetNameComboBox->findData(loc.planetName, Qt::UserRole, Qt::MatchCaseSensitive);
if (idx==-1)
{
// Use Earth as default
idx = ui->planetNameComboBox->findData(QVariant("Earth"), Qt::UserRole, Qt::MatchCaseSensitive);
}
ui->planetNameComboBox->setCurrentIndex(idx);
setMapForLocation(loc);
// Set pointer position
ui->mapLabel->setCursorPos(loc.longitude, loc.latitude);
ui->deleteLocationFromListPushButton->setEnabled(StelApp::getInstance().getLocationMgr().canDeleteUserLocation(loc.getID()));
SolarSystem* ssm = GETSTELMODULE(SolarSystem);
PlanetP p = ssm->searchByEnglishName(loc.planetName);
LandscapeMgr* ls = GETSTELMODULE(LandscapeMgr);
if (ls->getFlagAtmosphereAutoEnable())
{
if (loc.planetName != StelApp::getInstance().getCore()->getCurrentLocation().planetName)
{
QSettings* conf = StelApp::getInstance().getSettings();
ls->setFlagAtmosphere(p->hasAtmosphere() & conf->value("landscape/flag_atmosphere", true).toBool());
ls->setFlagFog(p->hasAtmosphere() & conf->value("landscape/flag_fog", true).toBool());
}
}
// Reactivate edit signals
connectEditSignals();
}
示例10: Java_com_example_Gravity_Gravity_getGravityObjectPosZ
/*******************************************************************************
*
* FUNCTION NAME: getGravityObjectPosZ
*
*------------------------ DETAILED FUNCTION DESCRIPTION ------------------------
*
*
*******************************************************************************/
JNIEXPORT jdouble Java_com_example_Gravity_Gravity_getGravityObjectPosZ( JNIEnv* env, jobject obj, jint index )
{
double retVal;
retVal = mySolarSystem.getGravityObjectZ(index);
return retVal;
}
示例11: Java_com_example_Gravity_Gravity_getGravityNumObjects
/*******************************************************************************
*
* FUNCTION NAME: getGravityNumObjects
*
*------------------------ DETAILED FUNCTION DESCRIPTION ------------------------
*
*
*******************************************************************************/
JNIEXPORT jint Java_com_example_Gravity_Gravity_getGravityNumObjects( JNIEnv* env, jobject obj )
{
double retVal;
retVal = mySolarSystem.getNumObjects();
return retVal;
}
示例12: QPixmap
// Update the map for the given location.
void LocationDialog::setMapForLocation(const StelLocation& loc)
{
// Avoids usless processing
if (lastPlanet==loc.planetName && lastVisionMode==StelApp::getInstance().getVisionModeNight())
return;
QPixmap pixmap;
// Try to set the proper planet map image
if (loc.planetName=="Earth")
{
// Special case for earth, we don't want to see the clouds
pixmap = QPixmap(":/graphicGui/world.png");
}
else
{
SolarSystem* ssm = GETSTELMODULE(SolarSystem);
PlanetP p = ssm->searchByEnglishName(loc.planetName);
QString path;
if (p)
{
try
{
path = StelFileMgr::findFile("textures/"+p->getTextMapName());
}
catch (std::runtime_error& e)
{
qWarning() << "ERROR - could not find planet map for " << loc.planetName << e.what();
return;
}
pixmap = QPixmap(path);
}
}
if (StelApp::getInstance().getVisionModeNight())
{
ui->mapLabel->setPixmap(StelButton::makeRed(pixmap));
}
else
{
ui->mapLabel->setPixmap(pixmap);
}
// For caching
lastPlanet = loc.planetName;
lastVisionMode = StelApp::getInstance().getVisionModeNight();
}
示例13: collidesWithAnotherSystem
bool Galaxy::collidesWithAnotherSystem(SolarSystem system) const {
for (int i = 0; i < data->solarSystems.values().length(); i++) {
const SolarSystem existingSystem = data->solarSystems.values().at(i);
if (!(existingSystem.getX() + 32 < system.getX() || existingSystem.getX() > system.getX() + 32
|| existingSystem.getY() + 32 < system.getY() || existingSystem.getY() > system.getY() + 32)) {
return true;
}
}
return false;
}
示例14: Java_com_example_Gravity_Gravity_computeNewPositions
/*******************************************************************************
*
* FUNCTION NAME: computeNewPositions
*
*------------------------ DETAILED FUNCTION DESCRIPTION ------------------------
*
* numIterationsPerDisplayPoint - number of iterations to compute.
*
* computationTimeInterval - time in seconds per computation interval
*
*
* Computes a number of iterations of the gravitational interactions on the full system.
*
*******************************************************************************/
JNIEXPORT void Java_com_example_Gravity_Gravity_computeNewPositions( JNIEnv* env, jobject obj, jint numIterationsPerDisplayPoint, jdouble computationTimeInterval)
{
uint32_t index;
for(index=0;index<numIterationsPerDisplayPoint ; index++)
{
mySolarSystem.processTimeInterval(computationTimeInterval);
}
}
示例15: dAdt
void RK4::integrateSolarSystem(SolarSystem &system, double dt, int sunCheck)
{
// Creating vectors
int n_bodies = system.numberOfBodies();
std::vector<double> A = std::vector<double>(4*n_bodies);
std::vector<double> K1 = std::vector<double>(4*n_bodies);
std::vector<double> K2 = std::vector<double>(4*n_bodies);
std::vector<double> K3 = std::vector<double>(4*n_bodies);
std::vector<double> K4 = std::vector<double>(4*n_bodies);
// Setting up A
/* vector A = [x1, y1, vx1, vy1, (first body)
x2, y2, vx2, vy2, (second body)
... for all celestial bodies
*/
for(int i=0;i<n_bodies;i++)
{
CelestialBody *body = system.bodies[i];
A[4*i] = body->position.x();
A[4*i+1]= body->position.y();
A[4*i+2]= body->velocity.x();
A[4*i+3]= body->velocity.y();
}
// Runge-Kutta 4th order integration, start
K1= dAdt(system,A);
// Returning acceleration values to CelestialBody objects
for(int i=0;i<n_bodies;i++)
{
CelestialBody *body = system.bodies[i];
body->acceleration.set(K1[4*i+2], K1[4*i+3], 0);
}
// Runge-Kutta 4th order integration, continued
K1 = mult(K1,dt);
K2 = dAdt(system,add(A,mult(K1,1/2.0))); K2 = mult(K2,dt);
K3 = dAdt(system,add(A,mult(K2,1/2.0))); K3 = mult(K3,dt);
K4 = dAdt(system,add(A,K3)) ; K4 = mult(K4,dt);
// Combining (K1 + 2*K2 + 2*K3 + K4)/6 into K1
K1 = add(K1,K4);
K1 = add(K1,mult(K2,2));
K1 = add(K1,mult(K3,2));
K1 = mult(K1,1/6.0);
A = add(A,K1);
// Returning new position and velocity values to CelestialBody objects
for(int i=sunCheck;i<n_bodies;i++) // For stationary Sun, set startpoint i=1
{
CelestialBody *body = system.bodies[i];
body->position.set(A[4*i], A[4*i+1], 0);
body->velocity.set(A[4*i+2], A[4*i+3], 0);
}
}