From a1cb8b0e68d3bde25da1da00d6c13824128d70d7 Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Mon, 30 Apr 2012 15:19:59 +0000 Subject: [PATCH] now using the Koch Snowflake (from fractals.dat) instead of Cantor dust for fractals and fractals_random demo (changed built-in data). Looks better Also removed copying of fractals.dat to build dir from CMake file git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1272 7f0cb862-5218-0410-a997-914c9d46530a --- CMakeLists.txt | 19 ------------------- progs/demos/Fractals/fractals.c | 18 +++++++++++++----- progs/demos/Fractals_random/fractals_random.c | 18 +++++++++++++----- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b3c49b..c75e4fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -381,25 +381,6 @@ ADD_DEMO(spaceball progs/demos/spaceball/spaceball.c ADD_DEMO(subwin progs/demos/subwin/subwin.c) ADD_DEMO(timer progs/demos/timer/timer.c) -# finally, if any demos are built, copy needed files to output directory -# (currently, thats just the input file for the Fractals demo) -IF(FREEGLUT_BUILD_DEMOS) - # 1) copy fractals.dat from freeglut/progs/demos/Fractals - IF(BUILD_SHARED_LIBS) - SET(Frac_target Fractals) - ELSE() - SET(Frac_target Fractals_static) - ENDIF() - GET_TARGET_PROPERTY(DEMO_OUTPUT_DIRECTORY ${Frac_target} RUNTIME_OUTPUT_DIRECTORY) - ADD_CUSTOM_COMMAND( - TARGET ${Frac_target} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - ${PROJECT_SOURCE_DIR}/progs/demos/Fractals/fractals.dat - ${DEMO_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR} - ) -ENDIF() - # pkg-config support, to install at $(libdir)/pkgconfig # Define static build dependencies IF(WIN32) diff --git a/progs/demos/Fractals/fractals.c b/progs/demos/Fractals/fractals.c index 12d8989..ec49552 100644 --- a/progs/demos/Fractals/fractals.c +++ b/progs/demos/Fractals/fractals.c @@ -23,6 +23,7 @@ #include #include #include +#define FGH_PI 3.14159265358979323846 typedef struct { @@ -267,13 +268,20 @@ void readConfigFile ( char *fnme ) else /* No data file, set a default */ { printf ( "ERROR opening file <%s>\n", fnme ) ; - strcpy ( window_title, "Cantor Dust" ) ; - num_trans = 2 ; + strcpy ( window_title, "Koch Snowflake" ) ; + num_trans = 4 ; affine = (AffineTrans *)malloc ( num_trans * sizeof(AffineTrans) ) ; - affine[0].a00 = 0.25 ; affine[0].a01 = 0.00 ; affine[0].a10 = 0.00 ; affine[0].a11 = 0.25 ; + affine[0].a00 = 1/3. ; affine[0].a01 = 0.00 ; affine[0].a10 = 0.00 ; affine[0].a11 = 1/3. ; affine[0].b0 = 0.0 ; affine[0].b1 = 0.0 ; - affine[1].a00 = 0.25 ; affine[1].a01 = 0.00 ; affine[1].a10 = 0.00 ; affine[1].a11 = 0.25 ; - affine[1].b0 = 0.5 ; affine[1].b1 = 0.0 ; + + affine[1].a00 = 1/6. ; affine[1].a01 = -1/3.*sin(FGH_PI/3.) ; affine[1].a10 = 1/3.*sin(FGH_PI/3.) ; affine[1].a11 = 1/6. ; + affine[1].b0 = 1/3. ; affine[1].b1 = 0.0 ; + + affine[2].a00 = 1/6. ; affine[2].a01 = -1/3.*sin(-FGH_PI/3.) ; affine[2].a10 = 1/3.*sin(-FGH_PI/3.) ; affine[2].a11 = 1/6. ; + affine[2].b0 = 0.5 ; affine[2].b1 = sqrt(3)/6. ; + + affine[3].a00 = 1/3. ; affine[3].a01 = 0.00 ; affine[3].a10 = 0.00 ; affine[3].a11 = 1/3. ; + affine[3].b0 = 2/3. ; affine[3].b1 = 0.0 ; } for ( i = 0; i < num_trans; i++ ) diff --git a/progs/demos/Fractals_random/fractals_random.c b/progs/demos/Fractals_random/fractals_random.c index 176013f..0cf6d0d 100644 --- a/progs/demos/Fractals_random/fractals_random.c +++ b/progs/demos/Fractals_random/fractals_random.c @@ -25,6 +25,7 @@ #include #include #include +#define FGH_PI 3.14159265358979323846 #ifdef _MSC_VER /* DUMP MEMORY LEAKS */ #include @@ -311,13 +312,20 @@ void readConfigFile ( char *fnme ) else /* No data file, set a default */ { printf ( "ERROR opening file <%s>\n", fnme ) ; - strcpy ( window_title, "Cantor Dust" ) ; - num_trans = 2 ; + strcpy ( window_title, "Koch Snowflake" ) ; + num_trans = 4 ; affine = (AffineTrans *)malloc ( num_trans * sizeof(AffineTrans) ) ; - affine[0].a00 = 0.25 ; affine[0].a01 = 0.00 ; affine[0].a10 = 0.00 ; affine[0].a11 = 0.25 ; + affine[0].a00 = 1/3. ; affine[0].a01 = 0.00 ; affine[0].a10 = 0.00 ; affine[0].a11 = 1/3. ; affine[0].b0 = 0.0 ; affine[0].b1 = 0.0 ; - affine[1].a00 = 0.25 ; affine[1].a01 = 0.00 ; affine[1].a10 = 0.00 ; affine[1].a11 = 0.25 ; - affine[1].b0 = 0.5 ; affine[1].b1 = 0.0 ; + + affine[1].a00 = 1/6. ; affine[1].a01 = -1/3.*sin(FGH_PI/3.) ; affine[1].a10 = 1/3.*sin(FGH_PI/3.) ; affine[1].a11 = 1/6. ; + affine[1].b0 = 1/3. ; affine[1].b1 = 0.0 ; + + affine[2].a00 = 1/6. ; affine[2].a01 = -1/3.*sin(-FGH_PI/3.) ; affine[2].a10 = 1/3.*sin(-FGH_PI/3.) ; affine[2].a11 = 1/6. ; + affine[2].b0 = 0.5 ; affine[2].b1 = sqrt(3)/6. ; + + affine[3].a00 = 1/3. ; affine[3].a01 = 0.00 ; affine[3].a10 = 0.00 ; affine[3].a11 = 1/3. ; + affine[3].b0 = 2/3. ; affine[3].b1 = 0.0 ; } for ( i = 0; i < num_trans; i++ ) -- 1.7.10.4