Back to index

kdeartwork  4.3.2
Public Slots | Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes
KRotationSaver Class Reference

Main class of the KRotation screen saver. More...

#include <rotation.h>

Collaboration diagram for KRotationSaver:
Collaboration graph
[legend]

List of all members.

Public Slots

void doTimeStep ()
 slot is called if integration should proceed by ::sm_deltaT
void resizeGlArea (QResizeEvent *e)
 slot is called if setup dialog changes in size and the GL area should be adjusted

Public Member Functions

 KRotationSaver (WId drawable)
 Constructor of the KRotation screen saver object.
 ~KRotationSaver ()
 Destructor of the KPendulum screen saver object.
void readSettings ()
 read the saved settings from disk
void initData ()
 init physical quantities and set up the ode solver
double traceLengthSeconds (void) const
 Returns length of traces in seconds of visibility, parameter from setup dialog.
void setTraceLengthSeconds (const double &t)
 Sets the length of traces in seconds of visibility.
bool traceFlag (unsigned int n) const
 Flags indicating if the traces for x,y,z are shown.
void setTraceFlag (unsigned int n, const bool &flag)
 (Un)Sets the x,y,z traces flags.
bool randomTraces (void) const
 If flag is set to true the traces will be (de)activated randomly all 10 seconds.
void setRandomTraces (const bool &flag)
 (Un)Sets the random trace flag.
double Lz (void) const
 Returns the angular momentum.
void setLz (const double &Lz)
 Sets the angular momentum.
double initEulerTheta (void) const
 Returns initial eulerian angle theta of the top body at t=0 sec.
void setInitEulerTheta (const double &theta)
 Set the initial eulerian angle theta of the top body at t=0 sec.
const Vector3d & omega (void) const
 Returns constant reference to m_omega.
const std::deque< Matrix3d > & e (void) const
 Returns constant reference to m_e.
const Vector3d & J (void) const
 Returns constant reference to m_J.

Static Public Attributes

static const double sm_traceLengthSecondsLimitLower = 0.0
 Lower argument limit for setTraceLengthSeconds()
static const double sm_traceLengthSecondsLimitUpper = 99.0
 Upper argument limit for setTraceLengthSeconds()
static const double sm_traceLengthSecondsDefault = 3.0
 Default value of KRotationSaver::m_traceLengthSeconds.
static const bool sm_traceFlagDefault [3] = {false, false, true}
 Default values for KRotationSaver::m_traceFlag.
static const bool sm_randomTracesDefault = true
 Default value for KRotationSaver::m_randomTraces.
static const double sm_LzLimitLower = 0.0
 Lower argument limit for setLz()
static const double sm_LzLimitUpper = 500.0
 Upper argument limit for setLz()
static const double sm_LzDefault = 10.0
 Default value for KRotationSaver::m_Lz.
static const double sm_initEulerThetaLimitLower = 0.0
 Lower argument limit for setInitEulerTheta()
static const double sm_initEulerThetaLimitUpper = 180.0
 Upper argument limit for setInitEulerTheta()
static const double sm_initEulerThetaDefault = 0.03
 Default value for KRotationSaver::m_initEulerTheta.

Private Attributes

EulerOdeSolverm_solver
 The ode solver which is used to integrate the equations of motion.
RotationGLWidgetm_glArea
 Gl widget of simulation.
QTimer * m_timer
 Timer for the real time integration of the Euler equations.
Vector3d m_omega
 current rotation vector
std::deque< Matrix3d > m_e
 deque of matrices of figure axes in fixed frame coordinates.
const Vector3d m_J
 Momentum of inertia along figure axes.
double m_traceLengthSeconds
 Length of traces in seconds of visibility, parameter from setup dialog.
bool m_traceFlag [3]
 Flags indicating if the traces for x,y,z are shown.
bool m_randomTraces
 If flag is set to true the traces will be (de)activated randomly all 10 seconds.
double m_Lz
 Angular momentum.
double m_initEulerPhi
 Initial eulerian angles phi of the top body at t=0s.
double m_initEulerPsi
 Initial eulerian angles psi of the top body at t=0s.
double m_initEulerTheta
 Initial eulerian angles theta of the top body at t=0 sec.

Static Private Attributes

static const unsigned int sm_deltaT = 20
 Time step size for the integration in milliseconds.

Detailed Description

Main class of the KRotation screen saver.

This class implements KScreenSaver for the KRotation screen saver.

Definition at line 181 of file rotation.h.


Constructor & Destructor Documentation

KRotationSaver::KRotationSaver ( WId  drawable)

Constructor of the KRotation screen saver object.

Parameters:
drawableId of the window in which the screen saver is drawed

Initial settings are read from disk, the GL widget is set up and displayed and the eq. of motion solver is started.

Definition at line 488 of file rotation.cpp.

   : KScreenSaver(id),
     m_solver(0),
     m_glArea(0),
     m_timer(0),
     m_J(4,2,3),                // fixed box sizes!
     m_traceLengthSeconds(sm_traceLengthSecondsDefault),
     m_Lz(sm_LzDefault),
     m_initEulerPhi(0),
     m_initEulerPsi(0),
     m_initEulerTheta(sm_initEulerThetaDefault)
{
   // no need to set our parent widget's background here, the GL widget sets its
   // own background color

   readSettings();              // read global settings

   // init m_e1,m_e2,m_e3,m_omega, construct and init m_solver
   initData();

   // create gl widget w/o parent
   m_glArea = new RotationGLWidget(0, *this);
   embed(m_glArea);             // embed gl widget and resize it
   m_glArea->show();            // show embedded gl widget

   // set up cyclic timer
   m_timer = new QTimer(this);
   m_timer->start(sm_deltaT);
   connect(m_timer, SIGNAL(timeout()), this, SLOT(doTimeStep()));
}

Here is the call graph for this function:

Destructor of the KPendulum screen saver object.

Only KPendulumSaver::solver is destoyed.

Definition at line 519 of file rotation.cpp.

{
   m_timer->stop();

   // m_timer is automatically deleted with parent KRotationSaver
   delete m_glArea;
   delete m_solver;
}

Member Function Documentation

void KRotationSaver::doTimeStep ( ) [slot]

slot is called if integration should proceed by ::sm_deltaT

Definition at line 627 of file rotation.cpp.

{
   // integrate a step ahead
   m_solver->integrate(0.001*sm_deltaT);

   // read new y
   Vector12d y = m_solver->Y();

   std::deque<Vector3d>::size_type
      max_vec_length =
      static_cast<std::deque<Vector3d>::size_type>
      ( m_traceLengthSeconds/(0.001*sm_deltaT) );

   // construct matrix from solution vector
   // read out new body coordinate system
   Matrix3d et;
   for (int j=0; j<3; ++j)
   {
      et.col(j) = y.segment<3>(3*j+3);
   }

   m_e.push_front(et);

   if (max_vec_length > 0)
   {
      m_e.push_front(et);
      while (m_e.size() > max_vec_length)
      {
         m_e.pop_back();
      }
   }
   else
   {
      // only set the 1. element
      m_e.front() = et;
      // and delete all other emements
      if (m_e.size() > 1)
      {
         m_e.resize(1);
      }
   }

   // current rotation vector omega
   m_omega = m_e.front() * y.start<3>();

   // set new random traces every 10 seconds
   if (m_randomTraces)
   {
      static unsigned int counter=0;
      ++counter;
      if (counter > unsigned(10.0/(0.001*sm_deltaT)))
      {
         counter=0;
         for (int i=0; i<3; ++i)
         {
            m_traceFlag[i] = (rand()%2==1);
         }
      }
   }

   m_glArea->updateGL();

   // no need to restart timer here, it is a cyclic timer
}

Here is the call graph for this function:

Here is the caller graph for this function:

const std::deque<Matrix3d>& KRotationSaver::e ( void  ) const [inline]

Returns constant reference to m_e.

Definition at line 259 of file rotation.h.

      {
         return m_e;
      }

Here is the caller graph for this function:

init physical quantities and set up the ode solver

Definition at line 528 of file rotation.cpp.

{
   // rotation by phi around z = zhat axis
   Matrix3d et(AngleAxisd(m_initEulerPhi, Vector3d::UnitZ()));
   // rotation by theta around new x axis
   et = AngleAxisd(m_initEulerPhi, et.col(0)).toRotationMatrix() * et;
   // rotation by psi around new z axis
   et = AngleAxisd(m_initEulerPsi, et.col(2)).toRotationMatrix() * et;

   // set first vector in deque
   m_e.clear(); m_e.push_front(et);

   /* calc L in body frame:
    *
    * determine unit-axes of fixed frame in body coordinates, invert the
    * transformations above for unit vectors of the body frame */

   // rotation by -psi along z axis
   Matrix3d e_body(AngleAxisd(-m_initEulerPsi, Vector3d::UnitZ()));
   // rotation by -theta along new x axis
   e_body = AngleAxisd(-m_initEulerTheta, e_body.col(0)).toRotationMatrix() * e_body;

   // omega_body = L_body * J_body^(-1)
   // component-wise division because J_body is a diagonal matrix
   Vector3d omega_body = (m_Lz * e_body.col(2)).cwise() / m_J;

   // initial rotation vector
   m_omega = et * omega_body;

   // assemble initial y for solver
   Vector12d y;
   y.start<3>() = omega_body;
   // 3 basis vectors of body system in fixed coordinates
   y.segment<3>(3) = et.col(0);
   y.segment<3>(6) = et.col(1);
   y.segment<3>(9) = et.col(2);

   if (m_solver!=0)
   {
      // deleting the solver is necessary when parameters are changed in the
      // configuration dialog.
      delete m_solver;
   }
   // init solver
   m_solver = new EulerOdeSolver(
      0.0,      // t
      0.01,     // first dt step size estimation
      m_J[0], m_J[1], m_J[2], // A,B,C
      y,        // omega_body,e1,e2,e3
      1e-5);    // eps
}

Here is the call graph for this function:

Here is the caller graph for this function:

double KRotationSaver::initEulerTheta ( void  ) const [inline]

Returns initial eulerian angle theta of the top body at t=0 sec.

Definition at line 246 of file rotation.h.

      {
         return m_initEulerTheta;
      }

Here is the caller graph for this function:

const Vector3d& KRotationSaver::J ( void  ) const [inline]

Returns constant reference to m_J.

Definition at line 264 of file rotation.h.

      {
         return m_J;
      }

Here is the caller graph for this function:

double KRotationSaver::Lz ( void  ) const [inline]

Returns the angular momentum.

Definition at line 238 of file rotation.h.

      {
         return m_Lz;
      }

Here is the caller graph for this function:

const Vector3d& KRotationSaver::omega ( void  ) const [inline]

Returns constant reference to m_omega.

Definition at line 254 of file rotation.h.

      {
         return m_omega;
      }

Here is the caller graph for this function:

bool KRotationSaver::randomTraces ( void  ) const [inline]

If flag is set to true the traces will be (de)activated randomly all 10 seconds.

Parameter from setup dialog

Definition at line 227 of file rotation.h.

      {
         return m_randomTraces;
      }

Here is the caller graph for this function:

read the saved settings from disk

Definition at line 580 of file rotation.cpp.

{
   // read configuration settings from config file
   KConfigGroup config(KGlobal::config(), "Settings");

   // internal saver parameters are set to stored values or left at their
   // default values if stored values are out of range
   setTraceFlag(0, config.readEntry("x trace", sm_traceFlagDefault[0]));
   setTraceFlag(1, config.readEntry("y trace", sm_traceFlagDefault[1]));
   setTraceFlag(2, config.readEntry("z trace", sm_traceFlagDefault[2]));
   setRandomTraces(config.readEntry("random traces", sm_randomTracesDefault));
   setTraceLengthSeconds(
      config.readEntry("length", sm_traceLengthSecondsDefault));
   setLz(
      config.readEntry("Lz",     sm_LzDefault));
   setInitEulerTheta(
      config.readEntry("theta",  sm_initEulerThetaDefault));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KRotationSaver::resizeGlArea ( QResizeEvent *  e) [slot]

slot is called if setup dialog changes in size and the GL area should be adjusted

Definition at line 694 of file rotation.cpp.

{
   m_glArea->resize(e->size());
}
void KRotationSaver::setInitEulerTheta ( const double &  theta)

Set the initial eulerian angle theta of the top body at t=0 sec.

Definition at line 616 of file rotation.cpp.

{
   if ((theta >= sm_initEulerThetaLimitLower)
       && (theta <= sm_initEulerThetaLimitUpper))
   {
      m_initEulerTheta = theta;
   }
}

Here is the caller graph for this function:

void KRotationSaver::setLz ( const double &  Lz)

Sets the angular momentum.

Definition at line 608 of file rotation.cpp.

{
   if ((Lz >= sm_LzLimitLower) && (Lz <= sm_LzLimitUpper))
   {
      m_Lz = Lz;
   }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KRotationSaver::setRandomTraces ( const bool &  flag) [inline]

(Un)Sets the random trace flag.

Definition at line 232 of file rotation.h.

      {
         m_randomTraces = flag;
      }

Here is the caller graph for this function:

void KRotationSaver::setTraceFlag ( unsigned int  n,
const bool &  flag 
) [inline]

(Un)Sets the x,y,z traces flags.

Definition at line 220 of file rotation.h.

      {
         m_traceFlag[n] = flag;
      }

Here is the caller graph for this function:

void KRotationSaver::setTraceLengthSeconds ( const double &  t)

Sets the length of traces in seconds of visibility.

Definition at line 599 of file rotation.cpp.

Here is the caller graph for this function:

bool KRotationSaver::traceFlag ( unsigned int  n) const [inline]

Flags indicating if the traces for x,y,z are shown.

Only relevant if ::randomTraces is not set to true. Parameter from setup dialog

Definition at line 215 of file rotation.h.

      {
         return m_traceFlag[n];
      }

Here is the caller graph for this function:

double KRotationSaver::traceLengthSeconds ( void  ) const [inline]

Returns length of traces in seconds of visibility, parameter from setup dialog.

Definition at line 206 of file rotation.h.

      {
         return m_traceLengthSeconds;
      }

Here is the caller graph for this function:


Member Data Documentation

std::deque<Matrix3d> KRotationSaver::m_e [private]

deque of matrices of figure axes in fixed frame coordinates.

Each matrix column represents an axis vector

Definition at line 321 of file rotation.h.

Gl widget of simulation.

Definition at line 313 of file rotation.h.

Initial eulerian angles phi of the top body at t=0s.

Definition at line 338 of file rotation.h.

Initial eulerian angles psi of the top body at t=0s.

Definition at line 340 of file rotation.h.

Initial eulerian angles theta of the top body at t=0 sec.

Parameter from setup dialog

Definition at line 343 of file rotation.h.

const Vector3d KRotationSaver::m_J [private]

Momentum of inertia along figure axes.

Definition at line 323 of file rotation.h.

double KRotationSaver::m_Lz [private]

Angular momentum.

This is a constant of motion and points always into positive z direction. Parameter from setup dialog

Definition at line 335 of file rotation.h.

Vector3d KRotationSaver::m_omega [private]

current rotation vector

Definition at line 318 of file rotation.h.

If flag is set to true the traces will be (de)activated randomly all 10 seconds.

Parameter from setup dialog

Definition at line 332 of file rotation.h.

The ode solver which is used to integrate the equations of motion.

Definition at line 311 of file rotation.h.

QTimer* KRotationSaver::m_timer [private]

Timer for the real time integration of the Euler equations.

Definition at line 315 of file rotation.h.

bool KRotationSaver::m_traceFlag[3] [private]

Flags indicating if the traces for x,y,z are shown.

Only relevant if ::randomTraces is not set to true. Parameter from setup dialog

Definition at line 329 of file rotation.h.

Length of traces in seconds of visibility, parameter from setup dialog.

Definition at line 326 of file rotation.h.

const unsigned int KRotationSaver::sm_deltaT = 20 [static, private]

Time step size for the integration in milliseconds.

Used in KRotationSaver and RotationGLWidget.

Definition at line 308 of file rotation.h.

const double KRotationSaver::sm_initEulerThetaDefault = 0.03 [static]

Default value for KRotationSaver::m_initEulerTheta.

Definition at line 295 of file rotation.h.

const double KRotationSaver::sm_initEulerThetaLimitLower = 0.0 [static]

Lower argument limit for setInitEulerTheta()

Definition at line 291 of file rotation.h.

const double KRotationSaver::sm_initEulerThetaLimitUpper = 180.0 [static]

Upper argument limit for setInitEulerTheta()

Definition at line 293 of file rotation.h.

const double KRotationSaver::sm_LzDefault = 10.0 [static]

Default value for KRotationSaver::m_Lz.

Definition at line 288 of file rotation.h.

const double KRotationSaver::sm_LzLimitLower = 0.0 [static]

Lower argument limit for setLz()

Definition at line 284 of file rotation.h.

const double KRotationSaver::sm_LzLimitUpper = 500.0 [static]

Upper argument limit for setLz()

Definition at line 286 of file rotation.h.

const bool KRotationSaver::sm_randomTracesDefault = true [static]

Default value for KRotationSaver::m_randomTraces.

Definition at line 281 of file rotation.h.

const bool KRotationSaver::sm_traceFlagDefault = {false, false, true} [static]

Default values for KRotationSaver::m_traceFlag.

Definition at line 279 of file rotation.h.

const double KRotationSaver::sm_traceLengthSecondsDefault = 3.0 [static]

Default value of KRotationSaver::m_traceLengthSeconds.

Definition at line 276 of file rotation.h.

Lower argument limit for setTraceLengthSeconds()

Definition at line 272 of file rotation.h.

Upper argument limit for setTraceLengthSeconds()

Definition at line 274 of file rotation.h.


The documentation for this class was generated from the following files: