Commit 57281889 authored by Oliver Bock's avatar Oliver Bock

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