function [s_baseband_t, s_basebands_t, blade_dis_t] = baseband(points_t, dl, fs, TXphase)
    % Get baseband signal from given points
    % Radar is looking in x-direction

    % point_t -> 3D coordinates of all the moving segments in time ( [time, 3D coordinates, segment_idx ] )
    % dl -> how far apart are the segments separated (for integration) ->
    % just a constant that multiplies the baseband signal
    % fs -> sampling frequency
    % TXphase -> function which for a given time t returns phase
    % transmitted at that time

    % returns
    % s_baseband_t -> time signal as a sum of reflected signals from each
    % point
    % s_basebands_t -> time signals reflected from each individual point [time, object_idx]


    c = physconst("LightSpeed");  % m/s -> universal constant
    
    % Init empty variables
    blade_dis_t = zeros(size(points_t, 1), size(points_t, 3));
    phi_t = zeros(size(points_t, 1), size(points_t, 3));  % Phase after mixing
    s_basebands_t = zeros(size(points_t, 1), size(points_t, 3));

    % TXphase = @(t) 2*pi*(( f0.*t )); CW TXPhase

    for k = 1:size(points_t, 1)  % For all times
        for l = 1:size(points_t, 3)  % For all segments
            position = squeeze(points_t(k, :, l)); % position of the segment
            blade_dis_t(k,l) =  sqrt(dot(position, position)); % distance from radar located at the origin
            
            % Add propagation time to both sides (to never be in negative time)
            TXtime = (k-1)/fs - 2*blade_dis_t(k, l)/c + 2*blade_dis_t(k, l)/c;
            RXtime = (k-1)/fs + 2*blade_dis_t(k, l)/c;
            phi_t(k, l) = -TXphase(TXtime) + TXphase(RXtime);  % Mixing

            s_basebands_t(k, l) = exp(-sqrt(-1)*phi_t(k, l)); % signal from the phase lag
        end
    end

    s_baseband_t = sum(s_basebands_t*dl, 2); % Overall signal from all segments

end

