Commit 817406f3 authored by Oliver Bock's avatar Oliver Bock

Just to be on the safe side

* Use double precision
* No explicit float literals
parent 5761d7ec
This diff is collapsed.
...@@ -39,12 +39,12 @@ public: ...@@ -39,12 +39,12 @@ public:
virtual ~PulsarAnimationWidget(); virtual ~PulsarAnimationWidget();
void setFramePerSecond(const unsigned int fps); void setFramePerSecond(const unsigned int fps);
void setCompanionMass(const float mass); void setCompanionMass(const double mass);
void setPulsarMass(const float mass); void setPulsarMass(const double mass);
void setPulsarSpinFrequency(const float frequency); void setPulsarSpinFrequency(const double frequency);
void setPulsarSpinAxisInclination(const int degrees); void setPulsarSpinAxisInclination(const int degrees);
void setPulsarMagneticAxisInclination(const int degrees); void setPulsarMagneticAxisInclination(const int degrees);
void setPulsarSemiMajorAxis(const float length); void setPulsarSemiMajorAxis(const double length);
public slots: public slots:
void runAnimation(); void runAnimation();
...@@ -58,8 +58,8 @@ public slots: ...@@ -58,8 +58,8 @@ public slots:
signals: signals:
void pulsarSemiMajorAxisUpdated(double value); void pulsarSemiMajorAxisUpdated(double value);
void pulseProfileUpdated(const QVector<float>& data); void pulseProfileUpdated(const QVector<double>& data);
void pulsarAnimationStep(float stepSize); void pulsarAnimationStep(double stepSize);
void pulsarAnimationReset(); void pulsarAnimationReset();
private: private:
...@@ -73,7 +73,7 @@ private: ...@@ -73,7 +73,7 @@ private:
void updateOrbitPeriod(); void updateOrbitPeriod();
void updateOrbitRadii(); void updateOrbitRadii();
void updateCameraPosition(const int angleH, const int angleV, const float zoom); void updateCameraPosition(const int angleH, const int angleV, const double zoom);
void resetParameters(); void resetParameters();
void updatePulseProfile(); void updatePulseProfile();
...@@ -93,16 +93,16 @@ private: ...@@ -93,16 +93,16 @@ private:
int m_framesPerSecond; int m_framesPerSecond;
float m_pulsarRotationAngle; double m_pulsarRotationAngle;
float m_pulsarRotationDelta; double m_pulsarRotationDelta;
double m_orbitalPeriod; double m_orbitalPeriod;
float m_orbitRotationAngle; double m_orbitRotationAngle;
float m_orbitRotationDelta; double m_orbitRotationDelta;
float m_pulsarMass; double m_pulsarMass;
double m_pulsarSemiMajorAxis; double m_pulsarSemiMajorAxis;
float m_companionMass; double m_companionMass;
double m_companionSemiMajorAxis; double m_companionSemiMajorAxis;
int m_pulsarSpinAxisInclination; int m_pulsarSpinAxisInclination;
...@@ -116,15 +116,15 @@ private: ...@@ -116,15 +116,15 @@ private:
int m_mouseLastY; int m_mouseLastY;
int m_mouseAngleH; int m_mouseAngleH;
int m_mouseAngleV; int m_mouseAngleV;
float m_cameraZoom; double m_cameraZoom;
float m_cameraZoomLBound; double m_cameraZoomLBound;
float m_cameraPosX; double m_cameraPosX;
float m_cameraPosY; double m_cameraPosY;
float m_cameraPosZ; double m_cameraPosZ;
QVector<float> m_pulseProfile; QVector<double> m_pulseProfile;
static const float deg2rad; static const double deg2rad;
}; };
#endif /* PULSARANIMATIONWIDGET_H_ */ #endif /* PULSARANIMATIONWIDGET_H_ */
...@@ -72,14 +72,14 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ...@@ -72,14 +72,14 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
connect(ui.pulsarGlWidget, SIGNAL(pulsarSemiMajorAxisUpdated(double)), connect(ui.pulsarGlWidget, SIGNAL(pulsarSemiMajorAxisUpdated(double)),
this, SLOT(updatePulsarSemiMajorAxisValue(double))); this, SLOT(updatePulsarSemiMajorAxisValue(double)));
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(float)), connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(double)),
ui.pulseScopeWidget, SLOT(markerStep(float)), Qt::DirectConnection); ui.pulseScopeWidget, SLOT(markerStep(double)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationReset()), connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationReset()),
ui.pulseScopeWidget, SLOT(markerReset())); ui.pulseScopeWidget, SLOT(markerReset()));
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<float>&)), connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<double>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<float>&)), Qt::DirectConnection); ui.pulseScopeWidget, SLOT(drawCurve(const QVector<double>&)), Qt::DirectConnection);
} }
PulsatingScience::~PulsatingScience() PulsatingScience::~PulsatingScience()
...@@ -151,37 +151,37 @@ void PulsatingScience::on_pushStop_clicked() ...@@ -151,37 +151,37 @@ void PulsatingScience::on_pushStop_clicked()
void PulsatingScience::on_radioCompanionWD_toggled(bool checked) void PulsatingScience::on_radioCompanionWD_toggled(bool checked)
{ {
if(checked) { if(checked) {
ui.pulsarGlWidget->setCompanionMass(0.6f); ui.pulsarGlWidget->setCompanionMass(0.6);
ui.lcdCompanionMass->display(QString::number(0.6f, 'f', 1)); ui.lcdCompanionMass->display(QString::number(0.6, 'f', 1));
} }
} }
void PulsatingScience::on_radioCompanionSun_toggled(bool checked) void PulsatingScience::on_radioCompanionSun_toggled(bool checked)
{ {
if(checked) { if(checked) {
ui.pulsarGlWidget->setCompanionMass(1.0f); ui.pulsarGlWidget->setCompanionMass(1.0);
ui.lcdCompanionMass->display(QString::number(1.0f, 'f', 1)); ui.lcdCompanionMass->display(QString::number(1.0, 'f', 1));
} }
} }
void PulsatingScience::on_radioCompanionNS_toggled(bool checked) void PulsatingScience::on_radioCompanionNS_toggled(bool checked)
{ {
if(checked) { if(checked) {
ui.pulsarGlWidget->setCompanionMass(1.4f); ui.pulsarGlWidget->setCompanionMass(1.4);
ui.lcdCompanionMass->display(QString::number(1.4f, 'f', 1)); ui.lcdCompanionMass->display(QString::number(1.4, 'f', 1));
} }
} }
void PulsatingScience::on_sliderPulsarMass_valueChanged(int value) void PulsatingScience::on_sliderPulsarMass_valueChanged(int value)
{ {
ui.pulsarGlWidget->setPulsarMass(value * 0.1f); ui.pulsarGlWidget->setPulsarMass(value * 0.1);
ui.lcdPulsarMass->display(QString::number(value * 0.1f, 'f', 1)); ui.lcdPulsarMass->display(QString::number(value * 0.1, 'f', 1));
} }
void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value) void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value)
{ {
ui.pulsarGlWidget->setPulsarSpinFrequency(value * 0.1f); ui.pulsarGlWidget->setPulsarSpinFrequency(value * 0.1);
ui.lcdPulsarSpinFrequency->display(QString::number(value * 0.1f, 'f', 1)); ui.lcdPulsarSpinFrequency->display(QString::number(value * 0.1, 'f', 1));
} }
void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value) void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value)
...@@ -198,8 +198,8 @@ void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int v ...@@ -198,8 +198,8 @@ void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int v
void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value) void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value)
{ {
ui.pulsarGlWidget->setPulsarSemiMajorAxis(value * 0.001f); ui.pulsarGlWidget->setPulsarSemiMajorAxis(value * 0.001);
ui.lcdPulsarSemiMajorAxis->display(QString::number(value * 0.001f, 'f', 1)); ui.lcdPulsarSemiMajorAxis->display(QString::number(value * 0.001, 'f', 1));
ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black"); ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black");
} }
......
...@@ -42,16 +42,16 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent), ...@@ -42,16 +42,16 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent),
qWarning("Sorry, no multisampling support for pulse scope..."); qWarning("Sorry, no multisampling support for pulse scope...");
} }
m_scopeSizeH = 360.0f; m_scopeSizeH = 360.0;
m_scopeSizeV = 1.0f; m_scopeSizeV = 1.0;
m_path = NULL; m_path = NULL;
m_marker = m_scene.addLine(0.0f, 0.0f, 0.0f, m_scopeSizeV, QPen(Qt::red)); m_marker = m_scene.addLine(0.0, 0.0, 0.0, m_scopeSizeV, QPen(Qt::red));
m_marker->setZValue(1); m_marker->setZValue(1);
setScene(&m_scene); setScene(&m_scene);
m_data.fill(0.0f, m_scopeSizeH); m_data.fill(0.0, m_scopeSizeH);
drawCurve(m_data); drawCurve(m_data);
} }
...@@ -67,11 +67,11 @@ void PulseScopeWidget::resizeEvent(QResizeEvent *event) ...@@ -67,11 +67,11 @@ void PulseScopeWidget::resizeEvent(QResizeEvent *event)
fitInView(m_scene.itemsBoundingRect(), Qt::IgnoreAspectRatio); fitInView(m_scene.itemsBoundingRect(), Qt::IgnoreAspectRatio);
} }
void PulseScopeWidget::drawCurve(const QVector<float>& vector) void PulseScopeWidget::drawCurve(const QVector<double>& vector)
{ {
m_data = vector; m_data = vector;
QPainterPath pulsePath(QPoint(0.0f, m_scopeSizeV)); QPainterPath pulsePath(QPoint(0.0, m_scopeSizeV));
for(int i = 0; i < m_scopeSizeH; ++i) { for(int i = 0; i < m_scopeSizeH; ++i) {
pulsePath.lineTo(i, m_scopeSizeV - m_data.at(i)); pulsePath.lineTo(i, m_scopeSizeV - m_data.at(i));
} }
...@@ -83,12 +83,12 @@ void PulseScopeWidget::drawCurve(const QVector<float>& vector) ...@@ -83,12 +83,12 @@ void PulseScopeWidget::drawCurve(const QVector<float>& vector)
} }
} }
void PulseScopeWidget::markerStep(float stepSize) { void PulseScopeWidget::markerStep(double stepSize) {
static float x = 0.0f; static double x = 0.0;
if(x < m_scopeSizeH) { if(x < m_scopeSizeH) {
x += stepSize; x += stepSize;
m_marker->setLine(x, 0.0f, x, m_scopeSizeV); m_marker->setLine(x, 0.0, x, m_scopeSizeV);
} }
else { else {
x -= m_scopeSizeH; x -= m_scopeSizeH;
...@@ -96,5 +96,5 @@ void PulseScopeWidget::markerStep(float stepSize) { ...@@ -96,5 +96,5 @@ void PulseScopeWidget::markerStep(float stepSize) {
} }
void PulseScopeWidget::markerReset() { void PulseScopeWidget::markerReset() {
m_marker->setLine(0.0f, 0.0f, 0.0f, m_scopeSizeV); m_marker->setLine(0.0, 0.0, 0.0, m_scopeSizeV);
} }
...@@ -41,18 +41,18 @@ public: ...@@ -41,18 +41,18 @@ public:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
public slots: public slots:
void drawCurve(const QVector<float>& vector); void drawCurve(const QVector<double>& vector);
void markerStep(float stepSize); void markerStep(double stepSize);
void markerReset(); void markerReset();
private: private:
QGraphicsScene m_scene; QGraphicsScene m_scene;
QVector<float> m_data; QVector<double> m_data;
QGraphicsPathItem *m_path; QGraphicsPathItem *m_path;
QGraphicsLineItem *m_marker; QGraphicsLineItem *m_marker;
float m_scopeSizeH; double m_scopeSizeH;
float m_scopeSizeV; double m_scopeSizeV;
}; };
#endif /* PULSESCOPEWIDGET_H_ */ #endif /* PULSESCOPEWIDGET_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment