update: more tests

This commit is contained in:
2025-12-07 13:15:18 -05:00
parent 7eca677774
commit 5ddfc05da1

View File

@@ -1,4 +1,3 @@
#include <stdio.h>
#include "render.h"
#include "write_png.h"
@@ -9,15 +8,66 @@ int angle_to_pixel_white(double *angle, double *rgb) {
return 0;
}
int main(){
int W = 9;
int H = 9;
double w = 1;
System system = {W, H, w, angle_to_pixel_white};
double buffer[W*H*3];
render(&system, buffer, 10000, 1.0/256, 1e-1);
write_png("test_white.png", buffer, W, H);
int test(double *thetaphi, double *rgb){
int i = floor(8.0*thetaphi[0]/PI);
int j = floor(8.0*(thetaphi[1]+PI)/PI);
int k = (i+j)&1;
int l = floor(2*thetaphi[1]/PI);
rgb[0] = k;
rgb[1] = k;
rgb[2] = k;
switch (l%4) {
case 1:
rgb[1] = rgb[2] = 0;
break;
case 2:
rgb[0] = rgb[2] = 0;
break;
case 3:
rgb[0] = rgb[1] = 0;
break;
default:
break;
}
return 0;
}
int test2(double *thetaphi, double *rgb){
double tantheta = tan(PI-thetaphi[0]);
int i = (int)floor(4*tantheta*cos(thetaphi[1]));
int j = (int)floor(4*tantheta*sin(thetaphi[1]));
int k = (i+j)&1;
rgb[0] = 1-k;
rgb[1] = 1-k;
rgb[2] = 1-k;
return 0;
}
int test3(double *thetaphi, double *rgb){
double x = sin(thetaphi[0])*sin(thetaphi[1]);
double y = sin(thetaphi[0])*cos(thetaphi[1]);
double z = cos(thetaphi[0]);
double theta1 = atan2(hypot(z, x), y);
double phi1 = atan2(-z, x);
int i = (int)floor(16*theta1/PI);
int j = (int)floor(16*phi1/PI);
int k = (i+j)&1;
rgb[0] = 1-k;
rgb[1] = 1-k;
rgb[2] = 1-k;
return 0;
}
int main(){
int W = 1600;
int H = 900;
double w = 2;
System system = {W, H, w, test};
double *buffer = malloc(sizeof(double)*W*H*3);
render(&system, buffer, 10000, 1.0/256, 1e-1);
write_png("test_1.png", buffer, W, H);
free(buffer);
return 0;
}