function [g] = computeG(l, b, s, theta)
%CALCULATEG Summary of this function goes here
%   Detailed explanation goes here

% Calibration parameter extraction:
theta_xy = theta(1); theta_xz = theta(2); theta_yz = theta(3);
Sx = s(1); Sy = s(2); Sz = s(3);
Bx = b(1); By = b(2); Bz = b(3);

[n_meas, c] = size(l);

g = zeros(n_meas, c);

for i = 1:n_meas

    Vx = l(i, 1); Vy = l(i, 2); Vz = l(i, 3);

    g_x = (Vx - Bx)/Sx;
    g_y = (1/(Sy*cos(theta_xy)))*(Vy - By - ((Vx - Bx)/Sx)*Sy*sin(theta_xy));
    g_z = (1/(cos(theta_yz)*cos(theta_xz))) * (((Vz-Bz)/Sz) - ((Vx-Bx)/Sx)*sin(theta_xz) - ((sin(theta_yz)*cos(theta_xz))/(Sy*cos(theta_xy))) * (Vy - By - ((Vx-Bx)/Sx)*Sy*sin(theta_xy)));

    g(i, :) = [g_x g_y g_z]; % fill g matrix for each position

end

end