SEAMOUNT_COORDINATES = [-155.27 18.92];
data = load('a01_etopo_loihi.mat');
xLimits = [min(x), max(x)];
yLimits = [min(y), max(y)];
xGrid = {linspace(xLimits(1) - eps(xLimits(1)), xLimits(2) + eps(xLimits(2)), 480), ...
linspace(yLimits(1) - eps(yLimits(1)), yLimits(2) + eps(yLimits(2)), 481)};
zGrid = regularizeNd([x,y], z, xGrid, smoothness, 'cubic');
% equivalents ways to call regularizeNd
% zGrid = regularizeNd([x,y], z, xGrid, smoothness, 'cubic', 'normal');
% Upsample grid since we are using cubic interpolation
zFunction = griddedInterpolant(xGrid, zGrid);
xGrid2= {linspace(xLimits(1) - eps(xLimits(1)), xLimits(2) + eps(xLimits(2)), 2000), ...
linspace(yLimits(1) - eps(yLimits(1)), yLimits(2) + eps(yLimits(2)), 2001)};
xGrid2Expanded = cell(2,1);
[xGrid2Expanded{:}] = ndgrid(xGrid2{:});
zGrid2 = zFunction(xGrid2Expanded{1}, xGrid2Expanded{2});
surfaceHandle = surf(xGrid2{:}, zGrid2',"EdgeColor","none","FaceColor","interp");
contour3(xGrid2{:}, zGrid2', 22, 'k', 'LineWidth', 0.45);
scatter3(x, y, z, 10, GRAY, 'filled');
title('3D bathymetry view');
ylabel(colorbar, "Depth (m)");
% datatip(surfaceHandle, SEAMOUNT_COORDINATES(1), SEAMOUNT_COORDINATES(2), zFunction(SEAMOUNT_COORDINATES(1), SEAMOUNT_COORDINATES(2)));
% Copyright (c) 2016-2026 Jason Nicholson
% Licensed under the MIT License
% See LICENSE file in project root