Skip to content

Commit

Permalink
Use random locations when autopiloting (default now).
Browse files Browse the repository at this point in the history
  • Loading branch information
ttsiodras committed Jan 15, 2021
1 parent 335c46b commit 48926d5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
22 changes: 13 additions & 9 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,26 @@ You can then simply...

$ src/mandelSSE -h

Usage: ./src/mandelSSE [-a] [-s|-x] [-h] [WIDTH HEIGHT]
Usage: ./src/mandelSSE [-a] [-s|-x] [-h] [-f rate] [WIDTH HEIGHT]
Where:
-h Show this help message
-a Run in autopilot mode (default: mouse mode)
-s Use SSE and OpenMP
-x Use XaoS algorithm (default)
If WIDTH and HEIGHT are not provided, they default to: 800 600
-m Run in mouse-driven mode
-a Run in autopilot mode (default)
-x Use XaoS algorithm with SSE2 and OpenMP (default)
-s Use naive algorithm with SSE, SSE2 and OpenMP
-f fps Enforce upper bound of frames per second (default: 60)
(use 0 to run at full possible speed)

$ src/mandelSSE -a 1024 768
If WIDTH and HEIGHT are not provided, they default to: 1024 768

$ src/mandelSSE
(Runs in autopilot in 1024x768 window, using XaoS)

$ src/mandelSSE -s 1024 768
(Runs in mouse-driven SSE mode, in a 1024x768 window)
$ src/mandelSSE -s -m 800 600
(Runs in mouse-driven SSE mode, in a 800x600 window)
(left-click zooms-in, right-click zooms out)

$ src/mandelSSE -x 1024 768
$ src/mandelSSE -x -m 800 600
(same as before, but in XaoS mode - much faster, esp during deep zooms)

WHAT IS THIS, AGAIN?
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,26 @@ You can then simply...

$ src/mandelSSE -h

Usage: ./src/mandelSSE [-a] [-s|-x] [-h] [WIDTH HEIGHT]
Usage: ./src/mandelSSE [-a] [-s|-x] [-h] [-f rate] [WIDTH HEIGHT]
Where:
-h Show this help message
-a Run in autopilot mode (default: mouse mode)
-s Use SSE and OpenMP
-x Use XaoS algorithm (default)
If WIDTH and HEIGHT are not provided, they default to: 800 600
-m Run in mouse-driven mode
-a Run in autopilot mode (default)
-x Use XaoS algorithm with SSE2 and OpenMP (default)
-s Use naive algorithm with SSE, SSE2 and OpenMP
-f fps Enforce upper bound of frames per second (default: 60)
(use 0 to run at full possible speed)

$ src/mandelSSE -a 1024 768
If WIDTH and HEIGHT are not provided, they default to: 1024 768

$ src/mandelSSE
(Runs in autopilot in 1024x768 window, using XaoS)

$ src/mandelSSE -s 1024 768
(Runs in mouse-driven SSE mode, in a 1024x768 window)
$ src/mandelSSE -s -m 800 600
(Runs in mouse-driven SSE mode, in a 800x600 window)
(left-click zooms-in, right-click zooms out)

$ src/mandelSSE -x 1024 768
$ src/mandelSSE -x -m 800 600
(same as before, but in XaoS mode - much faster, esp during deep zooms)

WHAT IS THIS, AGAIN?
Expand Down
15 changes: 10 additions & 5 deletions src/mandel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <SDL.h>

// With this macro defined...
Expand All @@ -27,8 +29,8 @@ void usage(char *argv[])
printf("Usage: %s [-a] [-s|-x] [-h] [-f rate] [WIDTH HEIGHT]\n", argv[0]);
puts("Where:");
puts("\t-h\tShow this help message");
puts("\t-m\tRun in mouse-driven mode (default)");
puts("\t-a\tRun in autopilot mode");
puts("\t-m\tRun in mouse-driven mode");
puts("\t-a\tRun in autopilot mode (default)");
puts("\t-x\tUse XaoS algorithm with SSE2 and OpenMP (default)");
puts("\t-s\tUse naive algorithm with SSE, SSE2 and OpenMP");
puts("\t-f fps\tEnforce upper bound of frames per second (default: 60)");
Expand All @@ -39,7 +41,7 @@ void usage(char *argv[])

int main(int argc, char *argv[])
{
int opt, bAutoPilot = 0, bSSE = 0, fps = 60;
int opt, bAutoPilot = 1, bSSE = 0, fps = 60;

while ((opt = getopt(argc, argv, "hmaxsf:")) != -1) {
switch (opt) {
Expand Down Expand Up @@ -103,6 +105,8 @@ int main(int argc, char *argv[])
printf("\n[-] Mandelbrot Zoomer by Thanassis, version: %s\n", version);
if (!bAutoPilot)
puts("[-] NOTE: you can launch with option '-a' to enable autopilot.");
else
puts("[-] NOTE: you can launch with option '-m' to pilot with your mouse.");
printf("[-]\n[-] Mode: %s\n", bSSE ? "naive SSE" : "XaoS");
printf("[-] Autopilot: %s\n", bAutoPilot ? "On" : "Off");
printf("[-] Dimensions: %ld x %ld\n", MAXX, MAXY);
Expand All @@ -122,9 +126,10 @@ int main(int argc, char *argv[])

unsigned en, st = SDL_GetTicks();
unsigned frames;
if (bAutoPilot)
if (bAutoPilot) {
srand(time(NULL));
frames = autopilot();
else
} else
frames = mousedriven();
en = SDL_GetTicks();

Expand Down
21 changes: 15 additions & 6 deletions src/xaos.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <math.h> // for fabs
#include <float.h> // For DBL_MIN
#include <math.h>
#include <float.h>

#include "common.h"
#include "xaos.h"
Expand Down Expand Up @@ -230,13 +230,22 @@ void mandel(

int autopilot()
{
static double interesting_points[][2] = {
{-0.72996052273553402312, -0.24047620199671820851},
{-0.73162093699311890000, -0.25655927868100719680},
{-1.03178026025649338671, -0.36035584735925418887},
{-0.73174633145360257203, 0.21761907852168510535},
{-1.25616009010536688884, 0.39944527454476780326},
{-0.03804043691413014350, -0.98541408335385771711}
};
const int total_interesting_points =
sizeof(interesting_points) / sizeof(interesting_points[0]);
int rand_idx = rand() % total_interesting_points;
double targetx = interesting_points[rand_idx][0];
double targety = interesting_points[rand_idx][1];
int i = 0;
int x,y;
double xld = -2.2, yld=-1.1, xru=-2+(MAXX/MAXY)*3., yru=1.1;
const double
targetx = -0.72996052273553402312, targety = -0.24047620199671820851;
// targetx = -0.73162093699311890000, targety = -0.25655927868100719680;
// targetx = -1.03178026025649338671, targety = -0.36035584735925418887;

while(i<ZOOM_FRAMES) {
unsigned st = SDL_GetTicks();
Expand Down

0 comments on commit 48926d5

Please sign in to comment.