Compare commits

...
2 Commits
Author SHA1 Message Date
wyj 4d37621fc6 fix: fix chi(b) 2025-11-28 13:53:42 -05:00
wyj a9e145a48d add render logic 2025-11-28 13:24:29 -05:00
3 changed files with 51 additions and 1 deletions
+7
View File
@@ -11,3 +11,10 @@
#define bmin (1.5*sqrt(3.0)+5e-10) #define bmin (1.5*sqrt(3.0)+5e-10)
#define THETAERROR 100000 #define THETAERROR 100000
typedef struct {
int W;
int H;
double w; //width of the sensor. focal length=1
int (*angle_to_pixel)(double *, double *);
} System;
+1 -1
View File
@@ -28,7 +28,7 @@ static int jac(double phi, const double y[], double *dfdy, double dfdphi[], void
gsl_matrix *m = &dfdy_mat.matrix; gsl_matrix *m = &dfdy_mat.matrix;
gsl_matrix_set(m, 0, 0, 0.0); gsl_matrix_set(m, 0, 0, 0.0);
gsl_matrix_set(m, 0, 1, 1.0); gsl_matrix_set(m, 0, 1, 1.0);
gsl_matrix_set(m, 1, 0, 63*M*y[0]-1.0); gsl_matrix_set(m, 1, 0, 6*M*y[0]-1.0);
gsl_matrix_set(m, 1, 1, 0.0); gsl_matrix_set(m, 1, 1, 0.0);
dfdphi[0] = 0.0; dfdphi[0] = 0.0;
+43
View File
@@ -0,0 +1,43 @@
#include <gsl/gsl_interp.h>
#include <gsl/gsl_spline.h>
#include "common.h"
#include "init.h"
int MC_pixel_render(const System *system, int i, int j, const gsl_spline *spline, double *rgb, int pixel_render_max, double pixel_render_err){
double dw = (system->w)/(system->W); // width and hight of one pixel
double x_lu = i*dw - (system->w)/2;
double y_lu = -j*dw + (system->H)*dw/2;
//TODO: fill the MC intergral
return 0;
}
int pixel_render(const System *system, int i, int j, const gsl_spline *spline, double *rgb, int pixel_render_max, double pixel_render_err){
return MC_pixel_render(system, i, j, spline, rgb, pixel_render_max, pixel_render_err);
}
int render(System *system, double **buffer, int pixel_render_max, double pixel_render_err, double chi_rela_err) {
double h = (system->H)*(system->w)/(system->W);
double tanpsi2 = (system->w)*(system->w)+h*h;
double cotpsi2 = 1/tanpsi2;
double bmax = R0/sqrt(f(R0)*(1+cotpsi2));
double *x=NULL;
double *y = NULL;
int size;
init(bmax, chi_rela_err, &size, &x, &y);
gsl_interp_accel *acc = gsl_interp_accel_alloc();
gsl_spline *spline = gsl_spline_alloc(gsl_interp_steffen, size);
gsl_spline_init(spline, x, y, size);
for(int j = 0; j < system->H; j++) {
for (int i = 0; i < system->W; i++) {
pixel_render(system, i, j, spline, buffer[j*(system->W) + i], pixel_render_max, pixel_render_err);
}
}
return 0;
}