summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-04-05 22:42:56 +0200
committertomsmeding <tom.smeding@gmail.com>2017-04-05 22:42:56 +0200
commitdb9351f8d2a3b4910858cf23367cafe5a39ff3eb (patch)
treeea0a53541eec98e1bf80c618801a3d18bdc6e596
parent4983354a6e0a2e690c02864d72f1c03ed3699f68 (diff)
Plot arg as hue, norm as value
-rw-r--r--attract.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/attract.c b/attract.c
index c4cba5c..5ab9aa7 100644
--- a/attract.c
+++ b/attract.c
@@ -19,6 +19,9 @@ const double EPS=1e-1;
static double complex att_func(double complex x,double exponent){
return clog((1-cpow(x,exponent+1))/(1-x));
+ // return x;
+ return x*x+CMPLX(-0.2,0.7);
+
// return csqrt(M_SQRT2*x); // sqrt(2) and 0
// return csqrt(1+x); // phi
// return csqrt(2*x-1); // attracts REALLY SLOWLY to 1+0i
@@ -26,20 +29,34 @@ static double complex att_func(double complex x,double exponent){
// return clog(x*x); // "241" basins
// return clog(x*x+x); // 3 basins but intricate structure
// return clog(x*x*x*x+x*x*x+x*x+x+1); // 2 basin fractal?
- // return csqrt(x*x*x+x*x+x+1);
+ // return csqrt(x*x*x+x*x+x+1); // lots of nans but really interesting lines
}
struct colour{
unsigned char r,g,b;
};
+static struct colour from_hue(double H){ // H in [0,1]
+ const int C=255;
+ double Hmod=H>=2.0/3 ? H-2.0/3 : H>=1.0/3 ? H-1.0/3 : H;
+ int X=C*(1-fabs(Hmod*6-1));
+ if(H<=1.0/6)return (struct colour){C,X,0};
+ if(H<=2.0/6)return (struct colour){X,C,0};
+ if(H<=3.0/6)return (struct colour){0,C,X};
+ if(H<=4.0/6)return (struct colour){0,X,C};
+ if(H<=5.0/6)return (struct colour){X,0,C};
+ return (struct colour){C,0,X};
+}
+
static struct colour make_colour(double complex z){
static const double N=3;
double norm=cabs(z);
if(norm>N)norm=N;
- int normclr=(int)(norm/N*255);
- int argclr=(int)((carg(z)+M_PI)/(2*M_PI)*255);
- return (struct colour){normclr,argclr,0};
+ struct colour clr=from_hue((carg(z)+M_PI)/(2*M_PI));
+ clr.r*=norm/N;
+ clr.g*=norm/N;
+ clr.b*=norm/N;
+ return clr;
}
struct config{
@@ -115,8 +132,8 @@ static void* thread_entry(void *arg_vp){
}
int main(int argc,char **argv){
- const double minx=-3,miny=-3;
- const double maxx=3,maxy=3;
+ const double minx=-1.5,miny=-1.5;
+ const double maxx=1.5,maxy=1.5;
const double width=1000;
struct config cfg={