oblique_mc

Monte Carlo in Single Layer Biological Tissue
git clone anongit@rnpnr.xyz:oblique_mc.git
Log | Files | Refs | Feed | README | LICENSE

Commit: e1220f4880f5d3b5942f1a4d99514ee32408c2b0
Parent: dfdab8960742c55dad0cce904bf6e9019b5413e1
Author: Randy Palamar
Date:   Sat, 30 Mar 2024 11:59:01 -0600

specify output extent instead of dx and dy

Diffstat:
Mconfig.def.h | 10++++++++--
Mmcml.c | 12++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,6 +1,6 @@ /* global data that will not be modified after startup */ static struct { - f64 dx, dy; /* cm */ + Rect extent; /* extent [cm] */ u32 Nx, Ny; u32 N_photons; @@ -12,8 +12,14 @@ static struct { f64 mu_t; f64 xoff, yoff; + f64 dx, dy; } gctx = { - .dx = 0.05, .dy = 0.05, + .extent = (Rect){ + .top = 1.5, + .bot = -1.5, + .left = -1.5, + .right = 1.5 + }, .Nx = 61, .Ny = 61, .N_photons = 10e6, diff --git a/mcml.c b/mcml.c @@ -32,6 +32,10 @@ typedef struct { } Vec3; typedef struct { + f64 top, bot, left, right; +} Rect; + +typedef struct { u32 Nx, Ny; f64 *b; } Mat2; @@ -66,8 +70,12 @@ die(const char *fmt, ...) static void init(void) { - gctx.xoff = gctx.dx * gctx.Nx / 2; - gctx.yoff = gctx.dy * gctx.Ny / 2; + f64 w = gctx.extent.right - gctx.extent.left; + f64 h = gctx.extent.top - gctx.extent.bot; + gctx.dx = w / gctx.Nx; + gctx.dy = h / gctx.Ny; + gctx.xoff = w / 2; + gctx.yoff = h / 2; gctx.mu_t = gctx.mu_a + gctx.mu_s; gctx.theta_i = gctx.theta_i * M_PI / 180; }