Commit 57281889 authored by Oliver Bock's avatar Oliver Bock
Browse files

Added inclination angle of spin axis (with respect to orbit angular momentum vector)

* Also: added missing parameter initializers (based on GUI settings, removed independent ones)
* Also: factored out parameter reset method
parent 5cfdb8f7
...@@ -45,13 +45,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) : ...@@ -45,13 +45,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_framesPerSecond = 25; m_framesPerSecond = 25;
setPulsarRotationDelta(0.5f); resetParameters();
setOrbitRotationDelta(0.2f);
setOrbitRadius(4.0f);
setPulsarMagneticAxisInclination(90);
m_pulsarRotationAngle = 0.0f;
m_orbitRotationAngle = 0.0f;
m_cameraInteraction = false; m_cameraInteraction = false;
m_mouseLastX = 0; m_mouseLastX = 0;
...@@ -163,6 +157,7 @@ void PulsarAnimationWidget::paintGL() ...@@ -163,6 +157,7 @@ void PulsarAnimationWidget::paintGL()
glPushMatrix(); glPushMatrix();
glRotatef(m_pulsarRotationAngle, 0.0f, 1.0f, 0.0f); glRotatef(m_pulsarRotationAngle, 0.0f, 1.0f, 0.0f);
glRotatef(m_pulsarSpinAxisInclination, 1.0f, 0.0f, 0.0f);
gluSphere(m_quadricPulsar, 1.0f, 32, 32); gluSphere(m_quadricPulsar, 1.0f, 32, 32);
glPopMatrix(); glPopMatrix();
...@@ -177,14 +172,14 @@ void PulsarAnimationWidget::paintGL() ...@@ -177,14 +172,14 @@ void PulsarAnimationWidget::paintGL()
glPushMatrix(); glPushMatrix();
glRotatef(m_pulsarRotationAngle - 90.0f, 0.0f, 1.0f, 0.0f); glRotatef(m_pulsarRotationAngle - 90.0f, 0.0f, 1.0f, 0.0f);
glRotatef(-m_pulsarMagneticAxisInclination + 90.0f, 1.0f, 0.0f, 0.0f); glRotatef(-m_pulsarMagneticAxisInclination - m_pulsarSpinAxisInclination + 90.0f, 1.0f, 0.0f, 0.0f);
glTranslatef(0.0f, 0.0f, -4.0f); glTranslatef(0.0f, 0.0f, -4.0f);
gluCylinder(m_quadricPulsarCone1, 0.5f, 0.0f, 3.0f, 32, 32); gluCylinder(m_quadricPulsarCone1, 0.5f, 0.0f, 3.0f, 32, 32);
glPopMatrix(); glPopMatrix();
glPushMatrix(); glPushMatrix();
glRotatef(m_pulsarRotationAngle + 90.0f, 0.0f, 1.0f, 0.0f); glRotatef(m_pulsarRotationAngle + 90.0f, 0.0f, 1.0f, 0.0f);
glRotatef(m_pulsarMagneticAxisInclination - 90.0f, 1.0f, 0.0f, 0.0f); glRotatef(m_pulsarMagneticAxisInclination + m_pulsarSpinAxisInclination - 90.0f, 1.0f, 0.0f, 0.0f);
glTranslatef(0.0f, 0.0f, -4.0f); glTranslatef(0.0f, 0.0f, -4.0f);
gluCylinder(m_quadricPulsarCone2, 0.5f, 0.0f, 3.0f, 32, 32); gluCylinder(m_quadricPulsarCone2, 0.5f, 0.0f, 3.0f, 32, 32);
glPopMatrix(); glPopMatrix();
...@@ -217,8 +212,7 @@ void PulsarAnimationWidget::pauseAnimation() ...@@ -217,8 +212,7 @@ void PulsarAnimationWidget::pauseAnimation()
void PulsarAnimationWidget::stopAnimation() void PulsarAnimationWidget::stopAnimation()
{ {
m_frameTimer.stop(); m_frameTimer.stop();
m_pulsarRotationAngle = 0.0; resetParameters();
m_orbitRotationAngle = 0.0;
updateGL(); updateGL();
} }
...@@ -278,6 +272,8 @@ void PulsarAnimationWidget::mouseMoveEvent(QMouseEvent *event) ...@@ -278,6 +272,8 @@ void PulsarAnimationWidget::mouseMoveEvent(QMouseEvent *event)
void PulsarAnimationWidget::mouseReleaseEvent(QMouseEvent *event) void PulsarAnimationWidget::mouseReleaseEvent(QMouseEvent *event)
{ {
Q_UNUSED(event);
m_mouseLastX = 0; m_mouseLastX = 0;
m_mouseLastY = 0; m_mouseLastY = 0;
m_cameraInteraction = false; m_cameraInteraction = false;
...@@ -315,9 +311,22 @@ void PulsarAnimationWidget::setOrbitRadius(const float radius) ...@@ -315,9 +311,22 @@ void PulsarAnimationWidget::setOrbitRadius(const float radius)
m_companionOrbitRadius = radius; m_companionOrbitRadius = radius;
} }
void PulsarAnimationWidget::setPulsarSpinAxisInclination(const int degrees)
{
m_pulsarSpinAxisInclination = degrees;
updateGL();
}
void PulsarAnimationWidget::setPulsarMagneticAxisInclination(const int degrees) void PulsarAnimationWidget::setPulsarMagneticAxisInclination(const int degrees)
{ {
m_pulsarMagneticAxisInclination = degrees; m_pulsarMagneticAxisInclination = degrees;
updateGL(); updateGL();
} }
void PulsarAnimationWidget::resetParameters()
{
m_pulsarRotationAngle = 0.0f;
m_orbitRotationAngle = 0.0f;
}
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
void setPulsarRotationDelta(const float frequency); void setPulsarRotationDelta(const float frequency);
void setOrbitRotationDelta(const float frequency); void setOrbitRotationDelta(const float frequency);
void setOrbitRadius(const float radius); void setOrbitRadius(const float radius);
void setPulsarSpinAxisInclination(const int degrees);
void setPulsarMagneticAxisInclination(const int degrees); void setPulsarMagneticAxisInclination(const int degrees);
...@@ -61,6 +62,7 @@ protected: ...@@ -61,6 +62,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
void updateCameraPosition(const int angleH, const int angleV, const float zoom); void updateCameraPosition(const int angleH, const int angleV, const float zoom);
void resetParameters();
QTimer m_frameTimer; QTimer m_frameTimer;
...@@ -80,6 +82,7 @@ protected: ...@@ -80,6 +82,7 @@ protected:
float m_pulsarOrbitRadius; float m_pulsarOrbitRadius;
float m_companionOrbitRadius; float m_companionOrbitRadius;
int m_pulsarSpinAxisInclination;
int m_pulsarMagneticAxisInclination; int m_pulsarMagneticAxisInclination;
bool m_cameraInteraction; bool m_cameraInteraction;
......
...@@ -39,6 +39,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent) ...@@ -39,6 +39,8 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
ui.pulsarGlWidget, SLOT(stopAnimation())); ui.pulsarGlWidget, SLOT(stopAnimation()));
on_sliderPulsarSpinFrequency_valueChanged(ui.sliderPulsarSpinFrequency->value()); on_sliderPulsarSpinFrequency_valueChanged(ui.sliderPulsarSpinFrequency->value());
on_sliderPulsarSpinAxisInclination_valueChanged(ui.sliderPulsarSpinAxisInclination->value());
on_sliderPulsarMagneticAxisInclination_valueChanged(ui.sliderPulsarMagneticAxisInclination->value());
on_sliderOrbitRadius_valueChanged(ui.sliderOrbitRadius->value()); on_sliderOrbitRadius_valueChanged(ui.sliderOrbitRadius->value());
on_sliderOrbitFrequency_valueChanged(ui.sliderOrbitFrequency->value()); on_sliderOrbitFrequency_valueChanged(ui.sliderOrbitFrequency->value());
} }
...@@ -54,6 +56,12 @@ void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value) ...@@ -54,6 +56,12 @@ void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value)
ui.lcdPulsarSpinFrequency->display(QString::number(value / 10.0, 'f', 1)); ui.lcdPulsarSpinFrequency->display(QString::number(value / 10.0, 'f', 1));
} }
void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value)
{
ui.pulsarGlWidget->setPulsarSpinAxisInclination(value);
ui.lcdPulsarSpinAxisInclination->display(QString::number(value));
}
void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int value) void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int value)
{ {
ui.pulsarGlWidget->setPulsarMagneticAxisInclination(value); ui.pulsarGlWidget->setPulsarMagneticAxisInclination(value);
......
...@@ -34,6 +34,7 @@ public: ...@@ -34,6 +34,7 @@ public:
public slots: public slots:
void on_sliderPulsarSpinFrequency_valueChanged(int value); void on_sliderPulsarSpinFrequency_valueChanged(int value);
void on_sliderPulsarSpinAxisInclination_valueChanged(int value);
void on_sliderPulsarMagneticAxisInclination_valueChanged(int value); void on_sliderPulsarMagneticAxisInclination_valueChanged(int value);
void on_sliderOrbitRadius_valueChanged(int value); void on_sliderOrbitRadius_valueChanged(int value);
void on_sliderOrbitFrequency_valueChanged(int value); void on_sliderOrbitFrequency_valueChanged(int value);
......
...@@ -92,21 +92,21 @@ ...@@ -92,21 +92,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="3" column="0" >
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_2" >
<property name="text" > <property name="text" >
<string>Orbit Radius:</string> <string>Orbit Radius:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" > <item row="4" column="0" >
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3" >
<property name="text" > <property name="text" >
<string>Orbit Frequency:</string> <string>Orbit Frequency:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="3" column="1" >
<widget class="QSlider" name="sliderOrbitRadius" > <widget class="QSlider" name="sliderOrbitRadius" >
<property name="minimum" > <property name="minimum" >
<number>1</number> <number>1</number>
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" > <item row="3" column="2" >
<widget class="QLCDNumber" name="lcdOrbitRadius" > <widget class="QLCDNumber" name="lcdOrbitRadius" >
<property name="numDigits" > <property name="numDigits" >
<number>6</number> <number>6</number>
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="2" > <item row="4" column="2" >
<widget class="QLCDNumber" name="lcdOrbitFrequency" > <widget class="QLCDNumber" name="lcdOrbitFrequency" >
<property name="numDigits" > <property name="numDigits" >
<number>6</number> <number>6</number>
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1" > <item row="4" column="1" >
<widget class="QSlider" name="sliderOrbitFrequency" > <widget class="QSlider" name="sliderOrbitFrequency" >
<property name="minimum" > <property name="minimum" >
<number>0</number> <number>0</number>
...@@ -180,19 +180,26 @@ ...@@ -180,19 +180,26 @@
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Spin Axis Incl.</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_4" >
<property name="text" > <property name="text" >
<string>Mag. Axis (incl.)</string> <string>Mag. Axis Incl.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="1" >
<widget class="QSlider" name="sliderPulsarMagneticAxisInclination" > <widget class="QSlider" name="sliderPulsarSpinAxisInclination" >
<property name="maximum" > <property name="maximum" >
<number>90</number> <number>180</number>
</property> </property>
<property name="value" > <property name="value" >
<number>90</number> <number>0</number>
</property> </property>
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -203,6 +210,35 @@ ...@@ -203,6 +210,35 @@
</widget> </widget>
</item> </item>
<item row="1" column="2" > <item row="1" column="2" >
<widget class="QLCDNumber" name="lcdPulsarSpinAxisInclination" >
<property name="numDigits" >
<number>6</number>
</property>
<property name="segmentStyle" >
<enum>QLCDNumber::Flat</enum>
</property>
<property name="intValue" stdset="0" >
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QSlider" name="sliderPulsarMagneticAxisInclination" >
<property name="maximum" >
<number>180</number>
</property>
<property name="value" >
<number>45</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition" >
<enum>QSlider::TicksBelow</enum>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QLCDNumber" name="lcdPulsarMagneticAxisInclination" > <widget class="QLCDNumber" name="lcdPulsarMagneticAxisInclination" >
<property name="numDigits" > <property name="numDigits" >
<number>6</number> <number>6</number>
...@@ -211,7 +247,7 @@ ...@@ -211,7 +247,7 @@
<enum>QLCDNumber::Flat</enum> <enum>QLCDNumber::Flat</enum>
</property> </property>
<property name="intValue" stdset="0" > <property name="intValue" stdset="0" >
<number>90</number> <number>45</number>
</property> </property>
</widget> </widget>
</item> </item>
......
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