move getRandomAxis to Mode superclass

This commit is contained in:
Josh Holtrop 2011-10-12 13:11:45 -04:00
parent 2f88a11652
commit cc2edd3a70
4 changed files with 15 additions and 10 deletions

14
modes/Mode.cc Normal file
View File

@ -0,0 +1,14 @@
#include <stdlib.h>
#include <math.h>
#include "Mode.h"
void Mode::getRandomAxis(float (*axis)[3])
{
double alpha = rand() / (double)RAND_MAX * 2.0 * M_PI;
double beta = rand() / (double)RAND_MAX * M_PI;
(*axis)[0] = cos(alpha) * sin(beta);
(*axis)[1] = sin(alpha) * sin(beta);
(*axis)[2] = cos(beta);
}

View File

@ -10,6 +10,7 @@ class Mode
virtual bool expose (GnomeScreensaver & gs) = 0;
virtual bool configure (GnomeScreensaver & gs) = 0;
virtual bool update (GnomeScreensaver & gs) = 0;
void getRandomAxis(float (*axis)[3]);
};
#endif /* MODE_H */

View File

@ -100,15 +100,6 @@ void Spin::initMonitorInfo()
}
}
void Spin::getRandomAxis(float (*axis)[3])
{
double alpha = rand() / (double)RAND_MAX * 2.0 * M_PI;
double beta = rand() / (double)RAND_MAX * M_PI;
(*axis)[0] = cos(alpha) * sin(beta);
(*axis)[1] = sin(alpha) * sin(beta);
(*axis)[2] = cos(beta);
}
uint32_t Spin::getRandomSwitchTime()
{
return 2000u + (uint32_t) (rand() / (double)RAND_MAX * 3000.0);

View File

@ -28,7 +28,6 @@ class Spin : public Mode
monitor_info_t *m_monitor_info;
uint64_t m_last_ticks;
void initMonitorInfo();
void getRandomAxis(float (*axis)[3]);
uint32_t getRandomSwitchTime();
float getRandomSpeed();
};