Adjust simulation planet radius according resolution

master
Stefan Jahn 3 years ago
parent 047c075a99
commit f95e0037b9

@ -55,8 +55,6 @@ int VideoDev_Simulation::Open() {
if (inframe != NULL) Close();
// conf_width = w;
// conf_height = h;
conf_format = convert_from_pixelformat (V4L2_PIX_FMT_RGB24);
simulation.SetResolution(conf_width, conf_height);
@ -119,10 +117,10 @@ int VideoDev_Simulation::CaptureStop() {
* If something goes wrong return an error code.
* Return code VDEV_STATUS_AGAIN is not an error. There was no video image ready to read.
*/
#define SIMULATION_SIZE 15
#define SIMULATION_SIZE 16
int VideoDev_Simulation::Grab(VideoFrame *vf) {
int posx, posy, x ,y;
double r, a, dsec;
int posx, posy, x ,y, r, radius;
double a, dsec;
// try to match a speed of 20Hz
dsec = get_cycletime(&lastframetv);
@ -131,7 +129,8 @@ int VideoDev_Simulation::Grab(VideoFrame *vf) {
memset (inframe, 0x0, conf_width*conf_height*3);
simulation.GetPos(&posx, &posy);
for (r = 1; r < SIMULATION_SIZE; r++) for (a = 0; a < M_PI * 2.0; a += 0.1) {
radius = conf_width * SIMULATION_SIZE / 1920;
for (r = 1; r < radius; r++) for (a = 0; a < M_PI * 2.0; a += 0.1) {
x = posx + (sin(a) * r);
y = posy + (cos(a) * r);
if (x >= 0 && x < conf_width && y >= 0 && y < conf_height) {
@ -308,4 +307,3 @@ void Simulation::AxisStop() {
axis[0].active = 0;
axis[1].active = 0;
}

Loading…
Cancel
Save