Browse Source

(committing very old stuff) Adds two new types

master
Joshua Moerman 9 years ago
parent
commit
d761ff97c2
  1. 15
      Attractor.hpp
  2. 6
      AttractorKernel.cpp
  3. 9
      AwesomeAttract0r.xcodeproj/project.pbxproj
  4. 9
      attractors/ceiling.stf
  5. 9
      attractors/test.stf
  6. 50
      attractors/tonemapper_test.stf
  7. 17
      attractors/unravel.stf
  8. 44
      kernels/Ceiling.hpp
  9. 46
      kernels/Test.hpp
  10. 47
      lyapunov.txt

15
Attractor.hpp

@ -41,7 +41,20 @@ public:
ProgressIndicator p(std::cout, LOG_VERBOSE, "searching for parameters"); ProgressIndicator p(std::cout, LOG_VERBOSE, "searching for parameters");
for(unsigned int i = 0; i < 1000000; i++) { for(unsigned int i = 0; i < 1000000; i++) {
iterate(); iterate();
if(kernel->convergent() || kernel->divergent()){
bool stop = false;
if(kernel->convergent()){
std::cerr << "convergent\n";
stop = true;
}
if(kernel->divergent()){
std::cerr << "divergent\n";
stop = true;
}
if(stop){
kernel->generate_random_parameters(); kernel->generate_random_parameters();
p.show(); p.show();
i = 0; i = 0;

6
AttractorKernel.cpp

@ -15,6 +15,8 @@
#include "kernels/Unravel3D.hpp" #include "kernels/Unravel3D.hpp"
#include "kernels/UnravelHeart3D.hpp" #include "kernels/UnravelHeart3D.hpp"
#include "kernels/Ikeda3D.hpp" #include "kernels/Ikeda3D.hpp"
#include "kernels/Ceiling.hpp"
#include "kernels/Test.hpp"
AttractorKernel* AttractorKernel::createAttractorKernel(stfu::node& attractor) { AttractorKernel* AttractorKernel::createAttractorKernel(stfu::node& attractor) {
@ -77,6 +79,10 @@ AttractorKernel* AttractorKernel::createAttractorKernel(stfu::node& attractor) {
LogError("something wrong\n"); LogError("something wrong\n");
exit(37); exit(37);
} }
} else if(attractorType == "ceiling"){
myAttractor = new Ceiling();
} else if(attractorType == "test"){
myAttractor = new Test();
} else { } else {
LogError("'%s' not recognized\n", attractorType.c_str()); LogError("'%s' not recognized\n", attractorType.c_str());
exit(37); exit(37);

9
AwesomeAttract0r.xcodeproj/project.pbxproj

@ -16,14 +16,13 @@
01C5707E13B63CF9009D151B /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C5707D13B63CF9009D151B /* libpng.a */; }; 01C5707E13B63CF9009D151B /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C5707D13B63CF9009D151B /* libpng.a */; };
4214149414A9D9B6004016D6 /* libboost_program_options.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4214149314A9D9B6004016D6 /* libboost_program_options.dylib */; }; 4214149414A9D9B6004016D6 /* libboost_program_options.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4214149314A9D9B6004016D6 /* libboost_program_options.dylib */; };
42CA52B9151F93940098800C /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C5707D13B63CF9009D151B /* libpng.a */; }; 42CA52B9151F93940098800C /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C5707D13B63CF9009D151B /* libpng.a */; };
42CA52BA151F93960098800C /* libboost_program_options.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4214149314A9D9B6004016D6 /* libboost_program_options.dylib */; }; 42CA52BA151F93960098800C /* libboost_program_options.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4214149314A9D9B6004016D6 /* libboost_program_options.dylib */; settings = {ATTRIBUTES = (Required, ); }; };
42CA52BB151F93A90098800C /* Projector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5700713B63AF0009D151B /* Projector.cpp */; }; 42CA52BB151F93A90098800C /* Projector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5700713B63AF0009D151B /* Projector.cpp */; };
42CA52BC151F93AB0098800C /* Projection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5704013B63BBE009D151B /* Projection.cpp */; }; 42CA52BC151F93AB0098800C /* Projection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5704013B63BBE009D151B /* Projection.cpp */; };
42CA52BD151F93AE0098800C /* Normalizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5704213B63BBE009D151B /* Normalizer.cpp */; }; 42CA52BD151F93AE0098800C /* Normalizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5704213B63BBE009D151B /* Normalizer.cpp */; };
42CA52BE151F93B30098800C /* AttractorKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5700F13B63AF0009D151B /* AttractorKernel.cpp */; }; 42CA52BE151F93B30098800C /* AttractorKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5700F13B63AF0009D151B /* AttractorKernel.cpp */; };
42CA52BF151F93BA0098800C /* stf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5703113B63B78009D151B /* stf.cpp */; }; 42CA52BF151F93BA0098800C /* stf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5703113B63B78009D151B /* stf.cpp */; };
42CA52C0151F93CF0098800C /* Attractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5701113B63AF0009D151B /* Attractor.cpp */; }; 42CA52C0151F93CF0098800C /* Attractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5701113B63AF0009D151B /* Attractor.cpp */; };
42CA52C2151F93E40098800C /* aatester.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CA52C1151F93E40098800C /* aatester.cpp */; };
42CA52C3151F93FC0098800C /* aatester.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CA52C1151F93E40098800C /* aatester.cpp */; }; 42CA52C3151F93FC0098800C /* aatester.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CA52C1151F93E40098800C /* aatester.cpp */; };
8DD76F650486A84900D96B5E /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.cpp */; settings = {ATTRIBUTES = (); }; }; 8DD76F650486A84900D96B5E /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.cpp */; settings = {ATTRIBUTES = (); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -77,6 +76,7 @@
01C5707D13B63CF9009D151B /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = /usr/local/lib/libpng.a; sourceTree = "<absolute>"; }; 01C5707D13B63CF9009D151B /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = /usr/local/lib/libpng.a; sourceTree = "<absolute>"; };
08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; 08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
4214149314A9D9B6004016D6 /* libboost_program_options.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libboost_program_options.dylib; path = /usr/local/lib/libboost_program_options.dylib; sourceTree = "<absolute>"; }; 4214149314A9D9B6004016D6 /* libboost_program_options.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libboost_program_options.dylib; path = /usr/local/lib/libboost_program_options.dylib; sourceTree = "<absolute>"; };
4253827E15B303F40014D6A2 /* Ceiling.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Ceiling.hpp; path = kernels/Ceiling.hpp; sourceTree = "<group>"; };
427057A61475637B00CBE978 /* Canvas.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Canvas.hpp; sourceTree = "<group>"; }; 427057A61475637B00CBE978 /* Canvas.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Canvas.hpp; sourceTree = "<group>"; };
427057A71475637B00CBE978 /* Image.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Image.hpp; sourceTree = "<group>"; }; 427057A71475637B00CBE978 /* Image.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Image.hpp; sourceTree = "<group>"; };
427057A81475637B00CBE978 /* ImageFormatBMP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatBMP.hpp; sourceTree = "<group>"; }; 427057A81475637B00CBE978 /* ImageFormatBMP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImageFormatBMP.hpp; sourceTree = "<group>"; };
@ -93,6 +93,7 @@
42CEC38414AB797200C3AEDA /* Random.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Random.hpp; sourceTree = "<group>"; }; 42CEC38414AB797200C3AEDA /* Random.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Random.hpp; sourceTree = "<group>"; };
42CEC38614ABB85200C3AEDA /* stf_ext.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = stf_ext.hpp; path = stfu/stf_ext.hpp; sourceTree = "<group>"; }; 42CEC38614ABB85200C3AEDA /* stf_ext.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = stf_ext.hpp; path = stfu/stf_ext.hpp; sourceTree = "<group>"; };
42CEC38714ABC2C000C3AEDA /* UnravelHeart3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = UnravelHeart3D.hpp; path = kernels/UnravelHeart3D.hpp; sourceTree = "<group>"; }; 42CEC38714ABC2C000C3AEDA /* UnravelHeart3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = UnravelHeart3D.hpp; path = kernels/UnravelHeart3D.hpp; sourceTree = "<group>"; };
42EAFCCD15F6551A006DC429 /* Test.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Test.hpp; path = kernels/Test.hpp; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -142,6 +143,8 @@
01C5703C13B63BA3009D151B /* Lorenz3D.hpp */, 01C5703C13B63BA3009D151B /* Lorenz3D.hpp */,
01C5703D13B63BA3009D151B /* Logistic.hpp */, 01C5703D13B63BA3009D151B /* Logistic.hpp */,
01C5703E13B63BA3009D151B /* Ikeda3D.hpp */, 01C5703E13B63BA3009D151B /* Ikeda3D.hpp */,
4253827E15B303F40014D6A2 /* Ceiling.hpp */,
42EAFCCD15F6551A006DC429 /* Test.hpp */,
); );
name = Kernels; name = Kernels;
sourceTree = "<group>"; sourceTree = "<group>";
@ -315,7 +318,6 @@
01C5703213B63B78009D151B /* stf.cpp in Sources */, 01C5703213B63B78009D151B /* stf.cpp in Sources */,
01C5704313B63BBE009D151B /* Projection.cpp in Sources */, 01C5704313B63BBE009D151B /* Projection.cpp in Sources */,
01C5704413B63BBE009D151B /* Normalizer.cpp in Sources */, 01C5704413B63BBE009D151B /* Normalizer.cpp in Sources */,
42CA52C2151F93E40098800C /* aatester.cpp in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -469,6 +471,7 @@
42CA52B6151F93650098800C /* Release with Symbols */, 42CA52B6151F93650098800C /* Release with Symbols */,
); );
defaultConfigurationIsVisible = 0; defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
}; };
/* End XCConfigurationList section */ /* End XCConfigurationList section */
}; };

9
attractors/ceiling.stf

@ -0,0 +1,9 @@
Projector: "Projector"
notes: "This is the version with `cheap` blur and random colours"
version: "Dec 28 2011 22:41:13"
Projector: {
}
attractor_kernel: {
dimensions: "2"
type: "ceiling"
}

9
attractors/test.stf

@ -0,0 +1,9 @@
Projector: "Projector"
notes: "This is the version with `cheap` blur and random colours"
version: "Dec 28 2011 22:41:13"
Projector: {
}
attractor_kernel: {
dimensions: "3"
type: "test"
}

50
attractors/tonemapper_test.stf

@ -0,0 +1,50 @@
Projector: "Projector"
notes: "This is the version with `cheap` blur and random colours"
version: "Dec 28 2011 22:41:13"
Projector: {
}
attractor_kernel: {
dimensions: "3"
type: "unravel"
parameters: {
: "-2.429328"
: "0.287420"
: "0.675572"
: "2.340503"
: "0.832299"
: "2.448456"
: "-2.795840"
}
}
tonemapper: {
class: "colorizer"
color_matrix: {
: {
: "-0.991366"
: "2.291840"
}
: {
: "3.043395"
: "0.333082"
}
: {
: "4.015293"
: "-8.064508"
}
}
gamma_matrix: {
: {
: "2.865378"
: "2.403487"
}
: {
: "1.411837"
: "2.752467"
}
: {
: "1.2"
: "2.0"
}
}
}

17
attractors/unravel.stf

@ -0,0 +1,17 @@
AttractorKernel: {
dimensions: "3"
type: "unravel"
parameters: {
: "0.761090"
: "1.426758"
: "1.516635"
: "-0.023669"
: "2.398894"
: "-0.324223"
: "-2.128391"
}
}
Projector: "Projector"
Projector: {
}

44
kernels/Ceiling.hpp

@ -0,0 +1,44 @@
//
// Ceiling.hpp
// AwesomeAttract0r
//
// Created by Joshua Moerman on 7/15/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
#ifndef AwesomeAttract0r_Ceiling_hpp
#define AwesomeAttract0r_Ceiling_hpp
#include <cmath>
class Ceiling : public AttractorKernel {
private:
void init() {
// setting some starting values
std::fill_n(vectorOld, dimension, 0.5);
std::fill_n(vectorNew, dimension, 0.5);
}
public:
Ceiling():
AttractorKernel(2, 2) {
init();
}
virtual std::string type() const { return "ceiling"; };
virtual void generate_random_parameters() {
parameters[0] = rand() / double(RAND_MAX) + 3.0;
parameters[1] = rand() / double(RAND_MAX) * 1.0 - 0.5;
init();
}
virtual void operator()() {
std::swap(vectorNew, vectorOld);
vectorNew[0] = parameters[1] + std::ceil(vectorOld[0]/vectorOld[1]) * vectorOld[1] * (1 - vectorOld[0]);
vectorNew[1] = (std::fmod(vectorOld[0],1) + parameters[0]) * vectorOld[1] * (1 - vectorOld[1]);
}
};
#endif

46
kernels/Test.hpp

@ -0,0 +1,46 @@
//
// Test.h
// AwesomeAttract0r
//
// Created by Joshua Moerman on 9/4/12.
// Copyright (c) 2012 Vadovas. All rights reserved.
//
#ifndef AwesomeAttract0r_Test_h
#define AwesomeAttract0r_Test_h
#include <cmath>
class Test : public AttractorKernel {
private:
void init() {
// setting some starting values
std::fill_n(vectorOld, dimension, 0.5);
std::fill_n(vectorNew, dimension, 0.5);
}
public:
Test():
AttractorKernel(3, 3) {
init();
}
virtual std::string type() const { return "test"; };
virtual void generate_random_parameters() {
parameters[0] = rand() / double(RAND_MAX) + 3.0;
parameters[1] = rand() / double(RAND_MAX) * 1.0 - 0.5;
parameters[2] = 2.0 * rand() / double(RAND_MAX) - 1.0;
init();
}
virtual void operator()() {
std::swap(vectorNew, vectorOld);
vectorNew[0] = parameters[1] + std::ceil(vectorOld[0]/vectorOld[1]) * vectorOld[1] * (1 - vectorOld[0]) + parameters[2] * vectorOld[2];
vectorNew[1] = (std::fmod(vectorOld[0],1) + parameters[0]) * vectorOld[1] * (1 - vectorOld[1]);
vectorNew[2] = vectorOld[0] * vectorOld[1] + vectorNew[0] * vectorNew[1] + rand() / double(RAND_MAX);
}
};
#endif

47
lyapunov.txt

@ -0,0 +1,47 @@
fractal dimension (actually the correlation dimension)
int counts[2] = {0};
r = 0.006 * totalSize;
for(j = 1:1000){
x0 = x;
for(i = 1:1000){
x = f(x);
if( |x - x0| <= r )
++counts[0];
if( |x - x0| <= 10*r )
++counts[1];
}
}
return log(counts[1] / counts[0]) / log(10.0);
lyapunov
double s = 0;
for(j = 1:1000){
x' = x + dx;
x = f(x);
x' = f(x');
s += log(|x' - x| / dx)
}
return s / N;
"The Lyapunov exponent is calculated as with the corresponding maps except that it is divided by e so that its units are bits per second rather than bits per iteration since each iteration advances the solution by e seconds. It is customary to express the Lyapunov exponent in this way for differential equations since the step size depends upon the numerical approximation that is being used whereas the divergence of the trajectories per unit time is an intrinsic property of the differential equations."
lyapunov 0, dimension 2 => torus
" For polynomial maps and ODEs the fractal dimension varies approximately as the square root of the embedding dimension."
entropy?
3 10%
x^3 = 0.1
log (0.1) / log (3)