Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
einsteinathome
pulsatingscience
Commits
ba9e75c1
Commit
ba9e75c1
authored
Dec 01, 2008
by
Oliver Bock
Browse files
Decoupled pulsar spin from orbital motion
parent
979152b1
Changes
2
Show whitespace changes
Inline
Side-by-side
src/pulsaranimationwidget.cpp
View file @
ba9e75c1
...
...
@@ -20,6 +20,8 @@
#include "pulsaranimationwidget.h"
const
float
PulsarAnimationWidget
::
deg2rad
=
PI
/
180.0
f
;
PulsarAnimationWidget
::
PulsarAnimationWidget
(
QWidget
*
parent
)
:
QGLWidget
(
parent
),
m_frameTimer
()
...
...
@@ -131,14 +133,17 @@ void PulsarAnimationWidget::paintGL()
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
low_shininess
);
glMaterialfv
(
GL_FRONT
,
GL_EMISSION
,
no_mat
);
glRotatef
(
m_orbitRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
glPushMatrix
();
glTranslatef
(
0.0
f
,
0.0
f
,
m_orbitRadiusNeg
);
glTranslatef
(
sin
((
m_orbitRotationAngle
+
180
)
*
deg2rad
)
*
m_companionOrbitRadius
,
0.0
f
,
cos
((
m_orbitRotationAngle
+
180
)
*
deg2rad
)
*
m_companionOrbitRadius
);
gluSphere
(
m_quadricPulsar
,
1.0
f
,
32
,
32
);
glPopMatrix
();
glTranslatef
(
0.0
f
,
0.0
f
,
m_orbitRadius
);
glPushMatrix
();
glTranslatef
(
sin
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
,
0.0
f
,
cos
(
m_orbitRotationAngle
*
deg2rad
)
*
m_pulsarOrbitRadius
);
glPushMatrix
();
glRotatef
(
m_pulsarRotationAngle
,
0.0
f
,
1.0
f
,
0.0
f
);
...
...
@@ -156,6 +161,7 @@ void PulsarAnimationWidget::paintGL()
glTranslatef
(
0.0
f
,
0.0
f
,
-
4.0
f
);
gluCylinder
(
m_quadricPulsarCone2
,
0.5
f
,
0.0
f
,
3.0
f
,
32
,
32
);
glPopMatrix
();
glPopMatrix
();
}
void
PulsarAnimationWidget
::
runAnimation
()
...
...
@@ -230,8 +236,6 @@ void PulsarAnimationWidget::mouseReleaseEvent(QMouseEvent *event)
void
PulsarAnimationWidget
::
updateCameraPosition
(
const
int
angleH
,
const
int
angleV
,
const
float
zoom
)
{
static
const
float
deg2rad
=
PI
/
180.0
f
;
m_cameraPosX
=
sin
(
angleH
*
deg2rad
)
*
zoom
;
m_cameraPosY
=
sin
(
angleV
*
deg2rad
)
*
zoom
;
m_cameraPosZ
=
cos
(
angleH
*
deg2rad
)
*
cos
(
fabs
(
angleV
*
deg2rad
))
*
zoom
;
...
...
@@ -256,6 +260,7 @@ void PulsarAnimationWidget::setOrbitRotationDelta(const float frequency)
void
PulsarAnimationWidget
::
setOrbitRadius
(
const
float
radius
)
{
m_orbitRadius
=
radius
;
m_orbitRadiusNeg
=
-
1.0
*
radius
;
// for the time being both have the same orbit (mass)
m_pulsarOrbitRadius
=
radius
;
m_companionOrbitRadius
=
radius
;
}
src/pulsaranimationwidget.h
View file @
ba9e75c1
...
...
@@ -70,10 +70,12 @@ protected:
float
m_pulsarRotationAngle
;
float
m_pulsarRotationDelta
;
float
m_orbitRotationAngle
;
float
m_orbitRotationDelta
;
float
m_orbitRadius
;
float
m_orbitRadiusNeg
;
float
m_pulsarOrbitRadius
;
float
m_companionOrbitRadius
;
int
m_mouseLastX
;
int
m_mouseLastY
;
...
...
@@ -84,6 +86,8 @@ protected:
float
m_cameraPosX
;
float
m_cameraPosY
;
float
m_cameraPosZ
;
static
const
float
deg2rad
;
};
#endif
/* PULSARANIMATIONWIDGET_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment