%clc;
clear all;
close all;

n_voxels = 2000;
n_proj = 3600;
r = 1060/16;
d = 1060;
detector_size = 400;
pix_size = 400/2000;
cor_offset = 0;
detector_offset_u = 0;
detector_offset_v = 0;
detector_offset_z = 0;
s = [0 0 0];
u_detector_r = [1 0 0];
v_detector_r = [0 1 0];
n_detector_r = [0 0 1];
proj_vol = zeros(n_voxels,n_voxels,n_proj);

x_o = (n_voxels+1)/2;
y_o = (n_voxels+1)/2;
z_o = (n_voxels+1)/2;

x_grid = (1:1:n_voxels)-x_o;
y_grid = (n_voxels:-1:1)-y_o;
z_grid = (1:1:n_voxels)-z_o;

vox_size = pix_size/16;

x_grid = single(x_grid*vox_size);
y_grid = single(y_grid*vox_size);
z_grid = single(z_grid*vox_size);

[slice_x,slice_y] = meshgrid(x_grid,y_grid);

n_threads = 1;

vol = fdk(int32(n_voxels),...
    int32(n_proj),...
    single(r),...
    single(d),...
    single(detector_size),...
    single(pix_size),...
    single(cor_offset),...
    single(detector_offset_u),...
    single(detector_offset_v),...
    single(detector_offset_z),...
    single(s),...
    single(u_detector_r),...
    single(v_detector_r),...
    single(n_detector_r),...
    single(proj_vol),...
    single(slice_x),...
    single(slice_y),...
    single(z_grid),...
    int32(n_threads));