function local = get_local_terrain(map, x, y)
%GET_LOCAL_TERRAIN Returns terrain properties at a continuous coordinate.
% Coordinates outside the map are considered non-traversable.

    local.z = interp2(map.X, map.Y, map.z, x, y, 'linear', NaN);
    local.mu = interp2(map.X, map.Y, map.mu, x, y, 'linear', NaN);
    local.slope_x = interp2(map.X, map.Y, map.slope_x, x, y, 'linear', NaN);
    local.slope_y = interp2(map.X, map.Y, map.slope_y, x, y, 'linear', NaN);
    local.slope_deg = interp2(map.X, map.Y, map.slope_deg, x, y, 'linear', NaN);
    local.obstacle = interp2(map.X, map.Y, double(map.obstacle), x, y, 'nearest', 1) > 0.5;
    local.traversable = interp2(map.X, map.Y, double(map.traversable), x, y, 'nearest', 0) > 0.5;

    if isnan(local.mu) || isnan(local.slope_deg)
        local.obstacle = true;
        local.traversable = false;
        local.mu = 0;
        local.slope_deg = Inf;
        local.slope_x = NaN;
        local.slope_y = NaN;
        local.z = NaN;
    end
end
