interp_spherical

Below is a demonstration of the features of the interp_spherical function

Contents

clear; close all; clc;

PLOT SETTINGS

fig_color='w';
fig_colordef='white';
font_size=10;

Simulating sparse sampling of complex spherical function

%A triangulated representation is constructed allowing for surface
%visualization. This is however not required.

%Start with sphere triangulation (Buckminster-Fuller type)
[F,V,Vs]=geoSphere(3,1);
T=Vs(:,1); P=Vs(:,2); %Spherical coordinates

%Modifying to obtain complex shape
[DCM,~]=euler2DCM([0.25.*pi -0.25*pi 0]); %Rotate
Vr=(V*DCM);
[Tr,Pr,Rr]=cart2sph(Vr(:,1),Vr(:,2),Vr(:,3)); %convert to spherical coordinates
[V(:,1),V(:,2),V(:,3)]=sph2cart(T,P,1+0.25*cos(2*(Tr))+0.25*cos(8*(P))); %Convert back with unity radii
V(:,3)=V(:,3)*2; %Scale
[T,P,R] = cart2sph(V(:,1),V(:,2),V(:,3)); %Convert to spherical coordinates

%Defining denser point set for interpolation
[Fi,Vi,Vsi]=geoSphere(4,1);
Ti=Vsi(:,1); Pi=Vsi(:,2); %Spherical coordinates

Spherical interpolation

%The function |interp_spherical| interpolates in a spherical coordinate
%sytem using standard interp2 type interpolation methods or those based on
%Delaunay tesselations in the angular space such as natural neighbour
%interpolation method. Standard spherical interpolation of this type
%creates artifacts at the poles. Hence |interp_spherical| splits the
%interpolation up into a number of steps (set by numberInterpSteps). The
%function aims to interpolate at the "equator" such that polar artifacts
%can be minimized. For each interpolation step the interpolation problem is
%rotated such that the currect "equatorial band" is centered at the
%equator. Running |interp_spherical| on its own without inputs or outputs
%shows a demo animation of this stepwise process.


numberInterpSteps=8; %Number of interpolation steps
interpMethod='natural'; %The interpolation method

%Spherical interpolation
[Ri]=interp_spherical(T,P,R,Ti,Pi,interpMethod,numberInterpSteps);

%Convert to Cartesian coordinates
[Vi(:,1),Vi(:,2),Vi(:,3)]=sph2cart(Ti,Pi,Ri);

%Plotting results
hf1=figuremax(fig_color,fig_colordef);
subplot(1,2,1); hold on; grid on; view(3);
xlabel('X','FontWeight','bold','FontSize',font_size); ylabel('Y','FontWeight','bold','FontSize',font_size); zlabel('Z','FontWeight','bold','FontSize',font_size);
title('Coarse original form','FontSize',font_size);
hp1=patch('Faces',F,'Vertices',V);
set(hp1,'FaceColor','g','EdgeColor','w');
axis equal tight vis3d;
camlight('headlight'); lighting phong;
set(gca,'FontSize',font_size);
drawnow;
ha=axis;
subplot(1,2,2); hold on; grid on; view(3);
xlabel('X','FontWeight','bold','FontSize',font_size); ylabel('Y','FontWeight','bold','FontSize',font_size); zlabel('Z','FontWeight','bold','FontSize',font_size);
title('Dense interpolated form','FontSize',font_size);
hp1=patch('Faces',Fi,'Vertices',Vi);
set(hp1,'FaceColor','r','EdgeColor','none');
axis equal tight vis3d;
axis(ha);
camlight('headlight'); lighting phong;
set(gca,'FontSize',font_size);
drawnow;

Animation of build in demo for interp_spherical

interp_spherical;
DEMO MODE

GIBBON www.gibboncode.org

Kevin Mattheus Moerman, [email protected]

GIBBON footer text

License: https://github.com/gibbonCode/GIBBON/blob/master/LICENSE

GIBBON: The Geometry and Image-based Bioengineering add-On. A toolbox for image segmentation, image-based modeling, meshing, and finite element analysis.

Copyright (C) 2017 Kevin Mattheus Moerman

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.