add render logic
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
43
src/render.c
Normal file
43
src/render.c
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user