summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-04-05 16:22:30 +0200
committertomsmeding <tom.smeding@gmail.com>2017-04-05 16:22:30 +0200
commiteb56ff93ac9bbf6fd8ddb2cc6891ddfde8f1b56c (patch)
treee2a9d1e287deb0de2e5695c13ea21e77c7bafce3
parent6354733cbf391f996c07b79be8466f66990ecd24 (diff)
Better config system
-rw-r--r--attract.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/attract.c b/attract.c
index 4526d0e..0ee39b6 100644
--- a/attract.c
+++ b/attract.c
@@ -46,6 +46,7 @@ static struct colour make_colour(double complex z){
struct config{
double unitsz;
int width,height;
+ double midx,midy;
double exponent;
};
@@ -78,8 +79,8 @@ static void* thread_entry(void *arg_vp){
for(int iy=ystart;iy<yend;iy++){
for(int ix=0;ix<cfg.width;ix++){
const double complex start=CMPLX(
- (double)(ix-cfg.width/2)/cfg.unitsz,
- (double)(iy-cfg.height/2)/cfg.unitsz);
+ (double)(ix-cfg.width/2)/cfg.unitsz+cfg.midx,
+ (double)(iy-cfg.height/2)/cfg.unitsz+cfg.midy);
double complex z=start;
for(int i=0;i<MAXITER;i++){
z=att_func(z,cfg.exponent);
@@ -115,12 +116,25 @@ static void* thread_entry(void *arg_vp){
}
int main(int argc,char **argv){
+ const double minx=-1.5,miny=-1.5;
+ const double maxx=1.5,maxy=1.5;
+ const double width=500;
+
struct config cfg={
- .unitsz=200,
- .width=500, .height=500,
+ .unitsz=width/(maxx-minx),
+ .width=width, .height=width*(maxy-miny)/(maxx-minx),
+ .midx=(maxx+minx)/2, .midy=(maxy+miny)/2,
.exponent=8.5
};
+ printf("Config:\n");
+ printf("unitsz = %lf\n",cfg.unitsz);
+ printf("width = %d\n",cfg.width);
+ printf("height = %d\n",cfg.height);
+ printf("midx = %lf\n",cfg.midx);
+ printf("midy = %lf\n",cfg.midy);
+ printf("exponent = %lf\n",cfg.exponent);
+
if(argc>=2){
cfg.exponent=strtod(argv[1],NULL);
}