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

Just to be on the safe side

* Use double precision
* No explicit float literals
parent 5761d7ec
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
#include "pulsaranimationwidget.h" #include "pulsaranimationwidget.h"
const float PulsarAnimationWidget::deg2rad = PI/180.0f; const double PulsarAnimationWidget::deg2rad = PI/180.0;
PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) : PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers), parent), QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers), parent),
m_frameTimer(), m_frameTimer(),
m_pulseProfile(360, 0.0f) m_pulseProfile(360, 0.0)
{ {
if(!format().directRendering()) { if(!format().directRendering()) {
qWarning("Sorry, no direct rendering support for animation..."); qWarning("Sorry, no direct rendering support for animation...");
...@@ -62,20 +62,20 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) : ...@@ -62,20 +62,20 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
// initial render timing settings // initial render timing settings
m_framesPerSecond = 25; m_framesPerSecond = 25;
m_pulsarRotationDelta = 0.0f; m_pulsarRotationDelta = 0.0;
m_orbitRotationDelta = 0.0f; m_orbitRotationDelta = 0.0;
resetParameters(); resetParameters();
// initial binary system parameters (have to match GUI!) // initial binary system parameters (have to match GUI!)
m_pulsarMass = 1.4f; m_pulsarMass = 1.4;
// initial companion is "Neutron Star" // initial companion is "Neutron Star"
m_companionMass = 1.4f; m_companionMass = 1.4;
m_pulsarSpinAxisInclination = 0.0f; m_pulsarSpinAxisInclination = 0.0;
m_pulsarMagneticAxisInclination = 45.0f; m_pulsarMagneticAxisInclination = 45.0;
m_pulsarSemiMajorAxis = 5.0f; m_pulsarSemiMajorAxis = 5.0;
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis; m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
// initial spin frequency of 0.5 Hz // initial spin frequency of 0.5 Hz
m_pulsarRotationDelta = (360.0f * 0.5f) / m_framesPerSecond; m_pulsarRotationDelta = (360.0 * 0.5) / m_framesPerSecond;
// update orbital period (based on settings above) // update orbital period (based on settings above)
updateOrbitPeriod(); updateOrbitPeriod();
...@@ -85,10 +85,10 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) : ...@@ -85,10 +85,10 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_cameraInteraction = false; m_cameraInteraction = false;
// initial view settings // initial view settings
m_mouseAngleH = 90.0f; m_mouseAngleH = 90.0;
m_mouseAngleV = 30.0f; m_mouseAngleV = 30.0;
m_cameraZoom = 15.0f; m_cameraZoom = 15.0;
m_cameraZoomLBound = 2.0f; m_cameraZoomLBound = 2.0;
m_mouseLastX = 0; m_mouseLastX = 0;
m_mouseLastY = 0; m_mouseLastY = 0;
...@@ -117,18 +117,18 @@ PulsarAnimationWidget::~PulsarAnimationWidget() ...@@ -117,18 +117,18 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
void PulsarAnimationWidget::initializeGL() void PulsarAnimationWidget::initializeGL()
{ {
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0f); glClearDepth(1.0);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
GLfloat LightAmbient[] = { 0.3f, 0.3f, 0.3f, 1.0f }; GLfloat LightAmbient[] = {0.3, 0.3, 0.3, 1.0};
GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightDiffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat LightSpecular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightSpecular[] = {1.0, 1.0, 1.0, 1.0};
GLfloat LightPosition[] = { 0.0f, 0.0f, 3.0f, 1.0f }; GLfloat LightPosition[] = {0.0, 0.0, 3.0, 1.0};
GLfloat spot_direction[] = { 0.0, 0.0, -1.0 }; GLfloat spot_direction[] = {0.0, 0.0, -1.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
...@@ -184,7 +184,7 @@ void PulsarAnimationWidget::resizeGL(int w, int h) ...@@ -184,7 +184,7 @@ void PulsarAnimationWidget::resizeGL(int w, int h)
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(45.0f, (GLfloat)w / (GLfloat)h, 0.1f, 500.0f); gluPerspective(45.0, (GLfloat)w / (GLfloat)h, 0.1, 500.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
...@@ -202,11 +202,11 @@ void PulsarAnimationWidget::paintGL() ...@@ -202,11 +202,11 @@ void PulsarAnimationWidget::paintGL()
0.0, 1.0, 0.0); 0.0, 1.0, 0.0);
// TODO: should be located elsewhere // TODO: should be located elsewhere
static GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; static GLfloat no_mat[] = {0.0, 0.0, 0.0, 1.0};
static GLfloat mat_diffuse[] = { 0.5, 0.5, 0.5, 1.0 }; static GLfloat mat_diffuse[] = {0.5, 0.5, 0.5, 1.0};
static GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; static GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};
static GLfloat low_shininess[] = { 2.5 }; static GLfloat low_shininess[] = {2.5};
static GLfloat translucent[] = { 1.0, 1.0, 1.0, 0.33 }; static GLfloat translucent[] = {1.0, 1.0, 1.0, 0.33};
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
...@@ -216,29 +216,29 @@ void PulsarAnimationWidget::paintGL() ...@@ -216,29 +216,29 @@ void PulsarAnimationWidget::paintGL()
// draw companion // draw companion
glPushMatrix(); glPushMatrix();
glTranslatef(sin((m_orbitRotationAngle + 180.0f) * deg2rad) * m_companionSemiMajorAxis, glTranslatef(sin((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis,
0.0f, 0.0,
cos((m_orbitRotationAngle + 180.0f) * deg2rad) * m_companionSemiMajorAxis); cos((m_orbitRotationAngle + 180.0) * deg2rad) * m_companionSemiMajorAxis);
gluSphere(m_quadricCompanion, 1.0f, 32, 32); gluSphere(m_quadricCompanion, 1.0, 32, 32);
glPopMatrix(); glPopMatrix();
// draw pulsar // draw pulsar
glPushMatrix(); glPushMatrix();
glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis, glTranslatef(sin(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis,
0.0f, 0.0,
cos(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis); cos(m_orbitRotationAngle * deg2rad) * m_pulsarSemiMajorAxis);
glPushMatrix(); glPushMatrix();
glRotatef(m_pulsarSpinAxisInclination, 0.0f, 0.0f, 1.0f); glRotatef(m_pulsarSpinAxisInclination, 0.0, 0.0, 1.0);
glRotatef(m_pulsarRotationAngle, 0.0f, 1.0f, 0.0f); glRotatef(m_pulsarRotationAngle, 0.0, 1.0, 0.0);
// draw spin axis // draw spin axis
if(m_showRotationAxes) { if(m_showRotationAxes) {
glPushMatrix(); glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glRotatef(90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0f, 0.0f, -5.0f); glTranslatef(0.0, 0.0, -5.0);
gluCylinder(m_quadricPulsarSpinAxis, 0.05f, 0.05f, 10.0f, 32, 1); gluCylinder(m_quadricPulsarSpinAxis, 0.05, 0.05, 10.0, 32, 1);
glPopMatrix(); glPopMatrix();
} }
...@@ -250,7 +250,7 @@ void PulsarAnimationWidget::paintGL() ...@@ -250,7 +250,7 @@ void PulsarAnimationWidget::paintGL()
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
gluSphere(m_quadricPulsar, 1.0f, 32, 32); gluSphere(m_quadricPulsar, 1.0, 32, 32);
// disable texturing // disable texturing
glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_S);
...@@ -259,49 +259,49 @@ void PulsarAnimationWidget::paintGL() ...@@ -259,49 +259,49 @@ void PulsarAnimationWidget::paintGL()
glPopMatrix(); glPopMatrix();
// TODO: should be located elsewhere // TODO: should be located elsewhere
static GLfloat coneAmbient[] = { 1.0, 1.0, 0.0, 1.0 }; static GLfloat coneAmbient[] = {1.0, 1.0, 0.0, 1.0};
static GLfloat coneDiffuse[] = { 1.0, 1.0, 0.0, 1.0 }; static GLfloat coneDiffuse[] = {1.0, 1.0, 0.0, 1.0};
static GLfloat coneSpecular[] = { 1.0, 1.0, 0.5, 1.0 }; static GLfloat coneSpecular[] = {1.0, 1.0, 0.5, 1.0};
glMaterialfv(GL_FRONT, GL_SPECULAR, coneSpecular); glMaterialfv(GL_FRONT, GL_SPECULAR, coneSpecular);
// first cone // first cone
glPushMatrix(); glPushMatrix();
glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glRotatef(90.0, 1.0, 0.0, 0.0);
glRotatef(m_pulsarSpinAxisInclination, 0.0f, 1.0f, 0.0f); glRotatef(m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0);
glRotatef(-m_pulsarRotationAngle - 90.0f, 0.0f, 0.0f, 1.0f); glRotatef(-m_pulsarRotationAngle - 90.0, 0.0, 0.0, 1.0);
glRotatef(-m_pulsarMagneticAxisInclination, 1.0f, 0.0f, 0.0f); glRotatef(-m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0);
// draw magnetic axis (for both cones) // draw magnetic axis (for both cones)
if(m_showRotationAxes) { if(m_showRotationAxes) {
glPushMatrix(); glPushMatrix();
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
glTranslatef(0.0f, 0.0f, -5.0f); glTranslatef(0.0, 0.0, -5.0);
gluCylinder(m_quadricPulsarMagneticAxis, 0.05f, 0.05f, 10.0f, 32, 1); gluCylinder(m_quadricPulsarMagneticAxis, 0.05, 0.05, 10.0, 32, 1);
glPopMatrix(); glPopMatrix();
} }
glTranslatef(0.0f, 0.0f, -4.0f); glTranslatef(0.0, 0.0, -4.0);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient); glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone1, 0.475f, 0.0f, 3.0f, 32, 32); gluCylinder(m_quadricPulsarCone1, 0.475, 0.0, 3.0, 32, 32);
glPopMatrix(); glPopMatrix();
// second cone // second cone
glPushMatrix(); glPushMatrix();
glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); glRotatef(-90.0, 1.0, 0.0, 0.0);
glRotatef(-m_pulsarSpinAxisInclination, 0.0f, 1.0f, 0.0f); glRotatef(-m_pulsarSpinAxisInclination, 0.0, 1.0, 0.0);
glRotatef(m_pulsarRotationAngle - 90.0f, 0.0f, 0.0f, 1.0f); glRotatef(m_pulsarRotationAngle - 90.0, 0.0, 0.0, 1.0);
glRotatef(m_pulsarMagneticAxisInclination, 1.0f, 0.0f, 0.0f); glRotatef(m_pulsarMagneticAxisInclination, 1.0, 0.0, 0.0);
glTranslatef(0.0f, 0.0f, -4.0f); glTranslatef(0.0, 0.0, -4.0);
glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient); glMaterialfv(GL_FRONT, GL_AMBIENT, coneAmbient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse); glMaterialfv(GL_FRONT, GL_DIFFUSE, coneDiffuse);
gluCylinder(m_quadricPulsarCone2, 0.475f, 0.0f, 3.0f, 32, 32); gluCylinder(m_quadricPulsarCone2, 0.475, 0.0, 3.0, 32, 32);
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
...@@ -309,15 +309,15 @@ void PulsarAnimationWidget::paintGL() ...@@ -309,15 +309,15 @@ void PulsarAnimationWidget::paintGL()
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glOrtho(0, width(), 0, height(), 0.1f, 501.0f); glOrtho(0, width(), 0, height(), 0.1, 501.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
// draw backdrop (independent parallel projection) // draw backdrop (independent parallel projection)
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, mat_specular);
glTranslatef(0.0f, 0.0f, -501.0f); glTranslatef(0.0, 0.0, -501.0);
drawTexture(QPointF(0.0f, 0.0f), m_backgroundTexture); drawTexture(QPointF(0.0, 0.0), m_backgroundTexture);
// restore original state // restore original state
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
...@@ -329,18 +329,18 @@ void PulsarAnimationWidget::paintGL() ...@@ -329,18 +329,18 @@ void PulsarAnimationWidget::paintGL()
if(m_cameraInteraction || m_showOrbits) { if(m_cameraInteraction || m_showOrbits) {
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, translucent);
static float sizeOffset = 0.25f; static double sizeOffset = 0.25;
// companion's plane (only if not identical with pulsar's) // companion's plane (only if not identical with pulsar's)
if(m_companionSemiMajorAxis != m_pulsarSemiMajorAxis) { if(m_companionSemiMajorAxis != m_pulsarSemiMajorAxis) {
glPushMatrix(); glPushMatrix();
glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glRotatef(90.0, 1.0, 0.0, 0.0);
// separate them slightly in case of overlap // separate them slightly in case of overlap
// based on ugly mass diff check (no collision detection) // based on ugly mass diff check (no collision detection)
// single known problematic pair: (m_c=1.4, m_p=1.5) // single known problematic pair: (m_c=1.4, m_p=1.5)
if((int)(10*(m_pulsarMass-m_companionMass)+0.5f) == 1){ if((int)(10*(m_pulsarMass-m_companionMass)+0.5) == 1){
glTranslatef(0.0f, 0.0f, 0.01f); glTranslatef(0.0, 0.0, 0.01);
} }
gluDisk(m_quadricCompanionOrbitPlane, gluDisk(m_quadricCompanionOrbitPlane,
...@@ -352,7 +352,7 @@ void PulsarAnimationWidget::paintGL() ...@@ -352,7 +352,7 @@ void PulsarAnimationWidget::paintGL()
// pulsar's plane // pulsar's plane
glPushMatrix(); glPushMatrix();
glRotatef(90.0f, 1.0f, 0.0f, 0.0f); glRotatef(90.0, 1.0, 0.0, 0.0);
gluDisk(m_quadricPulsarOrbitPlane, gluDisk(m_quadricPulsarOrbitPlane,
m_pulsarSemiMajorAxis - sizeOffset, m_pulsarSemiMajorAxis - sizeOffset,
m_pulsarSemiMajorAxis + sizeOffset, m_pulsarSemiMajorAxis + sizeOffset,
...@@ -363,7 +363,7 @@ void PulsarAnimationWidget::paintGL() ...@@ -363,7 +363,7 @@ void PulsarAnimationWidget::paintGL()
void PulsarAnimationWidget::runAnimation() void PulsarAnimationWidget::runAnimation()
{ {
m_frameTimer.start(1000.0f / m_framesPerSecond); m_frameTimer.start(1000.0 / m_framesPerSecond);
} }
void PulsarAnimationWidget::pauseAnimation() void PulsarAnimationWidget::pauseAnimation()
...@@ -382,13 +382,13 @@ void PulsarAnimationWidget::stopAnimation() ...@@ -382,13 +382,13 @@ void PulsarAnimationWidget::stopAnimation()
void PulsarAnimationWidget::updateFrame() void PulsarAnimationWidget::updateFrame()
{ {
m_pulsarRotationAngle += m_pulsarRotationDelta; m_pulsarRotationAngle += m_pulsarRotationDelta;
if(m_pulsarRotationAngle > 360.0f) { if(m_pulsarRotationAngle > 360.0) {
m_pulsarRotationAngle -= 360.0f; m_pulsarRotationAngle -= 360.0;
updatePulseProfile(); updatePulseProfile();
} }
m_orbitRotationAngle += m_orbitRotationDelta; m_orbitRotationAngle += m_orbitRotationDelta;
if(m_orbitRotationAngle > 360.0f) { if(m_orbitRotationAngle > 360.0) {
m_orbitRotationAngle -= 360.0f; m_orbitRotationAngle -= 360.0;
} }
updateGL(); updateGL();
...@@ -423,12 +423,12 @@ void PulsarAnimationWidget::mouseMoveEvent(QMouseEvent *event) ...@@ -423,12 +423,12 @@ void PulsarAnimationWidget::mouseMoveEvent(QMouseEvent *event)
Qt::MouseButtons buttons = event->buttons(); Qt::MouseButtons buttons = event->buttons();
if((buttons & Qt::LeftButton) == Qt::LeftButton) { if((buttons & Qt::LeftButton) == Qt::LeftButton) {
if(m_mouseLastX != 0) { if(m_mouseLastX != 0) {
m_mouseAngleH -= (m_mouseLastX - event->x()) * 0.5f ; m_mouseAngleH -= (m_mouseLastX - event->x()) * 0.5 ;
m_mouseAngleH = m_mouseAngleH < 360 ? m_mouseAngleH : 0; m_mouseAngleH = m_mouseAngleH < 360 ? m_mouseAngleH : 0;
} }
if(m_mouseLastY != 0) { if(m_mouseLastY != 0) {
m_mouseAngleV -= (m_mouseLastY - event->y()) * 0.5f; m_mouseAngleV -= (m_mouseLastY - event->y()) * 0.5;
m_mouseAngleV = m_mouseAngleV < 90 ? m_mouseAngleV : 90; m_mouseAngleV = m_mouseAngleV < 90 ? m_mouseAngleV : 90;
m_mouseAngleV = m_mouseAngleV > -90 ? m_mouseAngleV : -90; m_mouseAngleV = m_mouseAngleV > -90 ? m_mouseAngleV : -90;
} }
...@@ -438,7 +438,7 @@ void PulsarAnimationWidget::mouseMoveEvent(QMouseEvent *event) ...@@ -438,7 +438,7 @@ void PulsarAnimationWidget::mouseMoveEvent(QMouseEvent *event)
} }
else if((buttons & Qt::RightButton) == Qt::RightButton) { else if((buttons & Qt::RightButton) == Qt::RightButton) {
if(m_mouseLastY != 0) { if(m_mouseLastY != 0) {
m_cameraZoom -= (m_mouseLastY - event->y()) * 0.5f; m_cameraZoom -= (m_mouseLastY - event->y()) * 0.5;
m_cameraZoom = m_cameraZoom >= m_cameraZoomLBound ? m_cameraZoom : m_cameraZoomLBound; m_cameraZoom = m_cameraZoom >= m_cameraZoomLBound ? m_cameraZoom : m_cameraZoomLBound;
updateCameraPosition(m_mouseAngleH, m_mouseAngleV, m_cameraZoom); updateCameraPosition(m_mouseAngleH, m_mouseAngleV, m_cameraZoom);
} }
...@@ -459,7 +459,7 @@ void PulsarAnimationWidget::mouseReleaseEvent(QMouseEvent *event) ...@@ -459,7 +459,7 @@ void PulsarAnimationWidget::mouseReleaseEvent(QMouseEvent *event)
updateGL(); updateGL();
} }
void PulsarAnimationWidget::updateCameraPosition(const int angleH, const int angleV, const float zoom) void PulsarAnimationWidget::updateCameraPosition(const int angleH, const int angleV, const double zoom)
{ {
m_cameraPosX = sin(angleH * deg2rad) * zoom; m_cameraPosX = sin(angleH * deg2rad) * zoom;
m_cameraPosY = sin(angleV * deg2rad) * zoom; m_cameraPosY = sin(angleV * deg2rad) * zoom;
...@@ -475,7 +475,7 @@ void PulsarAnimationWidget::setFramePerSecond(const unsigned int fps) ...@@ -475,7 +475,7 @@ void PulsarAnimationWidget::setFramePerSecond(const unsigned int fps)
m_framesPerSecond = fps; m_framesPerSecond = fps;
} }
void PulsarAnimationWidget::setPulsarSemiMajorAxis(const float length) void PulsarAnimationWidget::setPulsarSemiMajorAxis(const double length)
{ {
m_pulsarSemiMajorAxis = length; m_pulsarSemiMajorAxis = length;
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis; m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
...@@ -485,7 +485,7 @@ void PulsarAnimationWidget::setPulsarSemiMajorAxis(const float length) ...@@ -485,7 +485,7 @@ void PulsarAnimationWidget::setPulsarSemiMajorAxis(const float length)
updateGL(); updateGL();
} }
void PulsarAnimationWidget::setCompanionMass(const float mass) void PulsarAnimationWidget::setCompanionMass(const double mass)
{ {
m_companionMass = mass; m_companionMass = mass;
updateOrbitRadii(); updateOrbitRadii();
...@@ -494,7 +494,7 @@ void PulsarAnimationWidget::setCompanionMass(const float mass) ...@@ -494,7 +494,7 @@ void PulsarAnimationWidget::setCompanionMass(const float mass)
updateGL(); updateGL();
} }
void PulsarAnimationWidget::setPulsarMass(const float mass) void PulsarAnimationWidget::setPulsarMass(const double mass)
{ {
m_pulsarMass = mass; m_pulsarMass = mass;
updateOrbitRadii(); updateOrbitRadii();
...@@ -503,9 +503,9 @@ void PulsarAnimationWidget::setPulsarMass(const float mass) ...@@ -503,9 +503,9 @@ void PulsarAnimationWidget::setPulsarMass(const float mass)
updateGL(); updateGL();
} }
void PulsarAnimationWidget::setPulsarSpinFrequency(const float frequency) void PulsarAnimationWidget::setPulsarSpinFrequency(const double frequency)
{ {
m_pulsarRotationDelta = (360.0f * frequency) / m_framesPerSecond; m_pulsarRotationDelta = (360.0 * frequency) / m_framesPerSecond;
updatePulseProfile(); updatePulseProfile();
} }
...@@ -528,8 +528,8 @@ void PulsarAnimationWidget::setPulsarMagneticAxisInclination(const int degrees) ...@@ -528,8 +528,8 @@ void PulsarAnimationWidget::setPulsarMagneticAxisInclination(const int degrees)
void PulsarAnimationWidget::updateOrbitPeriod() void PulsarAnimationWidget::updateOrbitPeriod()
{ {
m_orbitalPeriod = 3.1553e7 * sqrt( m_orbitalPeriod = 3.1553e7 * sqrt(
(pow(m_pulsarSemiMajorAxis, 3.0f) * pow(m_pulsarMass+m_companionMass, 2.0f)) / (pow(m_pulsarSemiMajorAxis, 3.0) * pow(m_pulsarMass+m_companionMass, 2.0)) /
pow(m_companionMass, 3.0f) pow(m_companionMass, 3.0)
); );
// visual correction factor (increase orbital momentum) // visual correction factor (increase orbital momentum)
...@@ -541,9 +541,9 @@ void PulsarAnimationWidget::updateOrbitPeriod() ...@@ -541,9 +541,9 @@ void PulsarAnimationWidget::updateOrbitPeriod()
void PulsarAnimationWidget::updateOrbitRadii() void PulsarAnimationWidget::updateOrbitRadii()
{ {
m_pulsarSemiMajorAxis = 1.0015e-5 * pow( m_pulsarSemiMajorAxis = 1.0015e-5 * pow(
(pow(m_orbitalPeriod, 2.0f) * pow(m_companionMass, 3.0f)) / (pow(m_orbitalPeriod, 2.0) * pow(m_companionMass, 3.0)) /
pow(m_pulsarMass+m_companionMass, 2.0f), pow(m_pulsarMass+m_companionMass, 2.0),
1.0f/3.0f 1.0/3.0
); );
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis; m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
...@@ -553,8 +553,8 @@ void PulsarAnimationWidget::updateOrbitRadii() ...@@ -553,8 +553,8 @@ void PulsarAnimationWidget::updateOrbitRadii()
void PulsarAnimationWidget::resetParameters() void PulsarAnimationWidget::resetParameters()
{ {
m_pulsarRotationAngle = 0.0f; m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0f; m_orbitRotationAngle = 0.0;
emit pulsarAnimationReset(); emit pulsarAnimationReset();
} }
...@@ -571,8 +571,8 @@ void PulsarAnimationWidget::updatePulseProfile() ...@@ -571,8 +571,8 @@ void PulsarAnimationWidget::updatePulseProfile()
const double xk = -m_cameraPosZ; const double xk = -m_cameraPosZ;
const double yk = -m_cameraPosX; const double yk = -m_cameraPosX;
const double zk = m_cameraPosY; const double zk = m_cameraPosY;
const double cam = pow(xk, 2.0f) + pow(yk, 2.0f) + pow(zk, 2.0f); const double cam = pow(xk, 2.0) + pow(yk, 2.0) + pow(zk, 2.0);
const double alpha = deg2rad * (90.0f - m_mouseAngleH); const double alpha = deg2rad * (90.0 - m_mouseAngleH);
const double delta = deg2rad * m_mouseAngleV; const double delta = deg2rad * m_mouseAngleV;
const double gaussProfile = 0.012337; const double gaussProfile = 0.012337;
...@@ -587,11 +587,8 @@ void PulsarAnimationWidget::updatePulseProfile() ...@@ -587,11 +587,8 @@ void PulsarAnimationWidget::updatePulseProfile()
double b = sqrt(pow(rp,2.0) + cam - (2.0 * sqrt(cam) * rp * cos(delta) * sin(alpha + phiOrb))); double b = sqrt(pow(rp,2.0) + cam - (2.0 * sqrt(cam) * rp * cos(delta) * sin(alpha + phiOrb)));
// determine pulse amplitude // determine and store pulse amplitude
double amp = exp(-2.0 * (1.0 - fabs(a/b)) / gaussProfile); m_pulseProfile[x] = exp(-2.0 * (1.0 - fabs(a/b)) / gaussProfile);
// store amplitude
m_pulseProfile[x] = (float) amp;
} }
// propagate new profile // propagate new profile
......
...@@ -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);