Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lagrange points L4 and L5 #3090

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 141 additions & 7 deletions src/core/modules/GridLinesMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class SkyPoint
SOLSTICES_OF_DATE,
ANTISOLAR,
EARTH_UMBRA_CENTER,
APEX
APEX,
LAGRANGE_SOLAR,
LAGRANGE_LUNAR
};
// Create and precompute positions of a SkyGrid
SkyPoint(SKY_POINT_TYPE _point_type = CELESTIALPOLES_J2000);
Expand All @@ -103,7 +105,7 @@ class SkyPoint
//! Re-translates the label.
void updateLabel();
private:
QSharedPointer<Planet> earth, sun;
QSharedPointer<Planet> earth, sun, moon;
SKY_POINT_TYPE point_type;
Vec3f color;
StelCore::FrameType frameType;
Expand Down Expand Up @@ -1479,6 +1481,7 @@ SkyPoint::SkyPoint(SKY_POINT_TYPE _point_type) : point_type(_point_type), color(

earth = GETSTELMODULE(SolarSystem)->getEarth();
sun = GETSTELMODULE(SolarSystem)->getSun();
moon = GETSTELMODULE(SolarSystem)->getMoon();

updateLabel();
}
Expand Down Expand Up @@ -1634,7 +1637,25 @@ void SkyPoint::updateLabel()
southernLabel += speedStr;
}
break;
}
}
case LAGRANGE_SOLAR:
{
frameType = StelCore::FrameHeliocentricEclipticJ2000;
// TRANSLATORS: Lagrange point L4
northernLabel = q_("L4(Sun-Planet)");
// TRANSLATORS: Lagrange point L5
southernLabel = q_("L5(Sun-Planet)");
break;
}
case LAGRANGE_LUNAR:
{
frameType = StelCore::FrameObservercentricEclipticJ2000;
// TRANSLATORS: Lagrange point L4
northernLabel = q_("L4(Earth-Moon)");
// TRANSLATORS: Lagrange point L5
southernLabel = q_("L5(Earth-Moon)");
break;
}
default:
Q_ASSERT(0);
}
Expand Down Expand Up @@ -1756,7 +1777,47 @@ void SkyPoint::draw(StelCore *core) const
sPainter.drawText(-dir, southernLabel, 0, shift, shift, false);
}
break;
}
}
case LAGRANGE_SOLAR:
{
// Takes the positional vector of the planet from the solar object
Vec3d pos= core->getCurrentObserver()->getHomePlanet()->getHeliocentricEclipticPos();
// Creates points by adding/subtracting 60 degrees to the vector along the common plane
// Vector orthogonal to pos vector, which should have z=0
Vec3d orth = Vec3d(pos.v[0]*cos(M_PI/2)-pos.v[1]*sin(M_PI/2),pos.v[1]*cos(M_PI/2)+pos.v[0]*sin(M_PI/2),0);
// Normal to the plane
Vec3d normal = pos^orth;
normal.normalize();
Vec3d l4 = cos(M_PI/3)*pos + sin(M_PI/3)*(normal^pos);
Vec3d l5 = cos(-M_PI/3)*pos + sin(-M_PI/3)*(normal^pos);

sPainter.drawSprite2dMode(l4, 5.f);
sPainter.drawText(l4, northernLabel, 0, shift, shift, false);
sPainter.drawSprite2dMode(l5, 5.f);
sPainter.drawText(l5, southernLabel, 0, shift, shift, false);

break;
}
case LAGRANGE_LUNAR:
{
// Takes the positional vector of the moon from the earth
const Vec3d pos = moon->getEclipticPos();
// Creates points by adding/subtracting 60 degrees to the vector along the common plane
// Vector orthogonal to pos vector, which should have z=0
Vec3d orth = Vec3d(pos.v[0]*cos(M_PI/2)-pos.v[1]*sin(M_PI/2),pos.v[1]*cos(M_PI/2)+pos.v[0]*sin(M_PI/2),0);
// Normal to the plane
Vec3d normal = pos^orth;
normal.normalize();
Vec3d l4 = cos(M_PI/3)*pos + sin(M_PI/3)*(normal^pos);
Vec3d l5 = cos(-M_PI/3)*pos + sin(-M_PI/3)*(normal^pos);

sPainter.drawSprite2dMode(l4, 5.f);
sPainter.drawText(l4, northernLabel, 0, shift, shift, false);
sPainter.drawSprite2dMode(l5, 5.f);
sPainter.drawText(l5, southernLabel, 0, shift, shift, false);

break;
}
default:
Q_ASSERT(0);
}
Expand Down Expand Up @@ -1816,6 +1877,8 @@ GridLinesMgr::GridLinesMgr()
antisolarPoint = new SkyPoint(SkyPoint::ANTISOLAR);
umbraCenterPoint = new SkyPoint(SkyPoint::EARTH_UMBRA_CENTER);
apexPoints = new SkyPoint(SkyPoint::APEX);
lagrangePointsSolar = new SkyPoint(SkyPoint::LAGRANGE_SOLAR);
lagrangePointsLunar = new SkyPoint(SkyPoint::LAGRANGE_LUNAR);

earth = GETSTELMODULE(SolarSystem)->getEarth();
connect(GETSTELMODULE(SolarSystem), SIGNAL(solarSystemDataReloaded()), this, SLOT(connectSolarSystem()));
Expand Down Expand Up @@ -1876,7 +1939,9 @@ GridLinesMgr::~GridLinesMgr()
delete solsticePoints;
delete antisolarPoint;
delete umbraCenterPoint;
delete apexPoints;
delete apexPoints;
delete lagrangePointsSolar;
delete lagrangePointsLunar;
SkyLine::deinit();
}

Expand Down Expand Up @@ -1977,6 +2042,8 @@ void GridLinesMgr::init()
setFlagAntisolarPoint(conf->value("viewing/flag_antisolar_point").toBool());
setFlagUmbraCenterPoint(conf->value("viewing/flag_umbra_center_point").toBool());
setFlagApexPoints(conf->value("viewing/flag_apex_points").toBool());
setFlagLagrangePointsSolar(conf->value("viewing/flag_lagrange_points_solar").toBool());
setFlagLagrangePointsLunar(conf->value("viewing/flag_lagrange_points_lunar").toBool());

// Set the line thickness for grids and lines
setLineThickness(conf->value("viewing/line_thickness", 1.f).toFloat());
Expand Down Expand Up @@ -2026,6 +2093,8 @@ void GridLinesMgr::init()
setColorSolsticePoints( Vec3f(conf->value("color/solstice_points_color", defaultColor).toString()));
setColorAntisolarPoint( Vec3f(conf->value("color/antisolar_point_color", defaultColor).toString()));
setColorApexPoints( Vec3f(conf->value("color/apex_points_color", defaultColor).toString()));
setColorLagrangePointsSolar( Vec3f(conf->value("color/lagrange_points_solar_color", defaultColor).toString()));
setColorLagrangePointsLunar( Vec3f(conf->value("color/lagrange_points_lunar_color", defaultColor).toString()));

StelApp& app = StelApp::getInstance();
connect(&app, SIGNAL(languageChanged()), this, SLOT(updateLabels()));
Expand Down Expand Up @@ -2076,6 +2145,8 @@ void GridLinesMgr::init()
addAction("actionShow_Antisolar_Point", displayGroup, N_("Antisolar point"), "antisolarPointDisplayed");
addAction("actionShow_Umbra_Center_Point", displayGroup, N_("The center of the Earth's umbra"), "umbraCenterPointDisplayed");
addAction("actionShow_Apex_Points", displayGroup, N_("Apex points"), "apexPointsDisplayed");
addAction("actionShow_Lagrange_Points_Solar", displayGroup, N_("Sun-planet lagrange points"), "lagrangePointsSolarDisplayed");
addAction("actionShow_Lagrange_Points_Lunar", displayGroup, N_("Earth-Moon lagrange points"), "lagrangePointsLunarDisplayed");
}

void GridLinesMgr::connectSolarSystem()
Expand Down Expand Up @@ -2135,6 +2206,8 @@ void GridLinesMgr::update(double deltaTime)
antisolarPoint->update(deltaTime);
umbraCenterPoint->update(deltaTime);
apexPoints->update(deltaTime);
lagrangePointsSolar->update(deltaTime);
lagrangePointsLunar->update(deltaTime);
apexPoints->updateLabel();
}

Expand Down Expand Up @@ -2181,6 +2254,7 @@ void GridLinesMgr::draw(StelCore* core)
longitudeLine->draw(core);
quadratureLine->draw(core);
umbraCenterPoint->draw(core);
lagrangePointsLunar->draw(core);
}
circumpolarCircleN->draw(core);
circumpolarCircleS->draw(core);
Expand Down Expand Up @@ -2208,7 +2282,7 @@ void GridLinesMgr::draw(StelCore* core)
solsticeJ2000Points->draw(core);
celestialJ2000Poles->draw(core);
celestialPoles->draw(core);

lagrangePointsSolar->draw(core);
zenithNadir->draw(core);
}

Expand Down Expand Up @@ -2252,7 +2326,9 @@ void GridLinesMgr::updateLabels()
solsticePoints->updateLabel();
antisolarPoint->updateLabel();
umbraCenterPoint->updateLabel();
apexPoints->updateLabel();
apexPoints->updateLabel();
lagrangePointsSolar->updateLabel();
lagrangePointsLunar->updateLabel();
}

//! Setter ("master switch") for displaying any grid/line.
Expand Down Expand Up @@ -2326,6 +2402,8 @@ void GridLinesMgr::setFlagAllPoints(const bool displayed)
setFlagSolsticeJ2000Points(displayed);
setFlagApexPoints(displayed);
setFlagUmbraCenterPoint(displayed);
setFlagLagrangePointsSolar(displayed);
setFlagLagrangePointsLunar(displayed);
}

//! Set flag for displaying Azimuthal Grid
Expand Down Expand Up @@ -3920,6 +3998,60 @@ void GridLinesMgr::setColorApexPoints(const Vec3f& newColor)
}
}

//! Set flag for displaying vector point
void GridLinesMgr::setFlagLagrangePointsSolar(const bool displayed)
{
if(displayed != lagrangePointsSolar->isDisplayed())
{
lagrangePointsSolar->setDisplayed(displayed);
emit lagrangePointsSolarDisplayedChanged(displayed);
}
}
//! Get flag for displaying vector point
bool GridLinesMgr::getFlagLagrangePointsSolar() const
{
return lagrangePointsSolar->isDisplayed();
}
Vec3f GridLinesMgr::getColorLagrangePointsSolar() const
{
return lagrangePointsSolar->getColor();
}
void GridLinesMgr::setColorLagrangePointsSolar(const Vec3f& newColor)
{
if(newColor != lagrangePointsSolar->getColor())
{
lagrangePointsSolar->setColor(newColor);
emit lagrangePointsSolarColorChanged(newColor);
}
}

//! Set flag for displaying vector point
void GridLinesMgr::setFlagLagrangePointsLunar(const bool displayed)
{
if(displayed != lagrangePointsLunar->isDisplayed())
{
lagrangePointsLunar->setDisplayed(displayed);
emit lagrangePointsLunarDisplayedChanged(displayed);
}
}
//! Get flag for displaying vector point
bool GridLinesMgr::getFlagLagrangePointsLunar() const
{
return lagrangePointsLunar->isDisplayed();
}
Vec3f GridLinesMgr::getColorLagrangePointsLunar() const
{
return lagrangePointsLunar->getColor();
}
void GridLinesMgr::setColorLagrangePointsLunar(const Vec3f& newColor)
{
if(newColor != lagrangePointsLunar->getColor())
{
lagrangePointsLunar->setColor(newColor);
emit lagrangePointsLunarColorChanged(newColor);
}
}

void GridLinesMgr::setLineThickness(const float thickness)
{
float lineThickness = equGrid->getLineThickness();
Expand Down Expand Up @@ -4059,5 +4191,7 @@ void GridLinesMgr::setFontSizeFromApp(int size)
solsticeJ2000Points->setFontSize(pointFontSize);
solsticePoints->setFontSize(pointFontSize);
apexPoints->setFontSize(pointFontSize);
lagrangePointsSolar->setFontSize(pointFontSize);
lagrangePointsLunar->setFontSize(pointFontSize);
umbraCenterPoint->setFontSize(pointFontSize);
}
22 changes: 22 additions & 0 deletions src/core/modules/GridLinesMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ class GridLinesMgr : public StelModule
Q_PROPERTY(bool apexPointsDisplayed READ getFlagApexPoints WRITE setFlagApexPoints NOTIFY apexPointsDisplayedChanged)
Q_PROPERTY(Vec3f apexPointsColor READ getColorApexPoints WRITE setColorApexPoints NOTIFY apexPointsColorChanged)

Q_PROPERTY(bool lagrangePointsSolarDisplayed READ getFlagLagrangePointsSolar WRITE setFlagLagrangePointsSolar NOTIFY lagrangePointsSolarDisplayedChanged)
Q_PROPERTY(Vec3f lagrangePointsSolarColor READ getColorLagrangePointsSolar WRITE setColorLagrangePointsSolar NOTIFY lagrangePointsSolarColorChanged)

Q_PROPERTY(bool lagrangePointsLunarDisplayed READ getFlagLagrangePointsLunar WRITE setFlagLagrangePointsLunar NOTIFY lagrangePointsLunarDisplayedChanged)
Q_PROPERTY(Vec3f lagrangePointsLunarColor READ getColorLagrangePointsLunar WRITE setColorLagrangePointsLunar NOTIFY lagrangePointsLunarColorChanged)

Q_PROPERTY(float lineThickness READ getLineThickness WRITE setLineThickness NOTIFY lineThicknessChanged)
Q_PROPERTY(float partThickness READ getPartThickness WRITE setPartThickness NOTIFY partThicknessChanged)
public:
Expand Down Expand Up @@ -972,6 +978,16 @@ public slots:
//! Get the thickness of lines
float getPartThickness() const;

void setFlagLagrangePointsSolar(const bool displayed);
bool getFlagLagrangePointsSolar() const;
Vec3f getColorLagrangePointsSolar() const;
void setColorLagrangePointsSolar(const Vec3f& newColor);

void setFlagLagrangePointsLunar(const bool displayed);
bool getFlagLagrangePointsLunar() const;
Vec3f getColorLagrangePointsLunar() const;
void setColorLagrangePointsLunar(const Vec3f& newColor);

signals:
void gridlinesDisplayedChanged(const bool);
void lineThicknessChanged(const float);
Expand Down Expand Up @@ -1094,6 +1110,10 @@ public slots:
void umbraCenterPointDisplayedChanged(const bool displayed);
void apexPointsDisplayedChanged(const bool displayed);
void apexPointsColorChanged(const Vec3f & newColor);
void lagrangePointsSolarDisplayedChanged(const bool displayed);
void lagrangePointsSolarColorChanged(const Vec3f & newColor);
void lagrangePointsLunarDisplayedChanged(const bool displayed);
void lagrangePointsLunarColorChanged(const Vec3f & newColor);

private slots:
//! Re-translate the labels of the great circles.
Expand Down Expand Up @@ -1156,6 +1176,8 @@ private slots:
SkyPoint * antisolarPoint; // Antisolar point
SkyPoint * umbraCenterPoint; // The point of the center of umbra
SkyPoint * apexPoints; // Apex and Antapex points, i.e. the point where the observer planet is moving to or receding from
SkyPoint * lagrangePointsSolar; // Earth-Sun lagrange points
SkyPoint * lagrangePointsLunar;
};

#endif // GRIDLINESMGR_HPP
4 changes: 4 additions & 0 deletions src/gui/ViewDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ void ViewDialog::createDialogContent()
connectCheckBox(ui->showSolsticePointsCheckBox, "actionShow_Solstice_Points");
connectCheckBox(ui->showAntisolarPointCheckBox, "actionShow_Antisolar_Point");
connectCheckBox(ui->showApexPointsCheckBox, "actionShow_Apex_Points");
connectCheckBox(ui->showLagrangePointsSolarCheckBox, "actionShow_Lagrange_Points_Solar");
connectCheckBox(ui->showLagrangePointsLunarCheckBox, "actionShow_Lagrange_Points_Lunar");
connectCheckBox(ui->showFOVCenterMarkerCheckBox, "actionShow_FOV_Center_Marker");
connectCheckBox(ui->showFOVCircularMarkerCheckBox, "actionShow_FOV_Circular_Marker");
connectCheckBox(ui->showFOVRectangularMarkerCheckBox, "actionShow_FOV_Rectangular_Marker");
Expand Down Expand Up @@ -485,6 +487,8 @@ void ViewDialog::createDialogContent()
connectColorButton(ui->colorSolsticePoints, "GridLinesMgr.solsticePointsColor", "color/solstice_points_color");
connectColorButton(ui->colorAntisolarPoint, "GridLinesMgr.antisolarPointColor", "color/antisolar_point_color");
connectColorButton(ui->colorApexPoints, "GridLinesMgr.apexPointsColor", "color/apex_points_color");
connectColorButton(ui->colorLagrangePointsSolar, "GridLinesMgr.lagrangePointsSolarColor", "color/lagrange_points_solar_color");
connectColorButton(ui->colorLagrangePointsLunar, "GridLinesMgr.lagrangePointsLunarColor", "color/lagrange_points_lunar_color");
connectColorButton(ui->colorFOVCenterMarker, "SpecialMarkersMgr.fovCenterMarkerColor", "color/fov_center_marker_color");
connectColorButton(ui->colorFOVCircularMarker, "SpecialMarkersMgr.fovCircularMarkerColor", "color/fov_circular_marker_color");
connectColorButton(ui->colorFOVRectangularMarker, "SpecialMarkersMgr.fovRectangularMarkerColor", "color/fov_rectangular_marker_color");
Expand Down
40 changes: 40 additions & 0 deletions src/gui/viewDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3821,6 +3821,26 @@
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QToolButton" name="colorLagrangePointsSolar">
<property name="toolTip">
<string>Color of Sun-Planet Lagrange points</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QToolButton" name="colorLagrangePointsLunar">
<property name="toolTip">
<string>Color of Earth-Moon Lagrange points</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QCheckBox" name="fixedEquatorPartsCheckBox">
<property name="toolTip">
Expand Down Expand Up @@ -4065,6 +4085,26 @@
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QCheckBox" name="showLagrangePointsSolarCheckBox">
<property name="toolTip">
<string>Sun-planet Lagrange points L4 and L5</string>
</property>
<property name="text">
<string>Sun-Planet Lagrange Points</string>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QCheckBox" name="showLagrangePointsLunarCheckBox">
<property name="toolTip">
<string>Earth-Moon Lagrange points L4 and L5</string>
</property>
<property name="text">
<string>Earth-Moon Lagrange Points</string>
</property>
</widget>
</item>
<item row="13" column="7">
<widget class="QToolButton" name="colorFOVCenterMarker">
<property name="toolTip">
Expand Down