Below is a demonstration for:



clear; close all; clc;

Plot settings

patchColorOuter=[64 120 192]/255;

Control parameters

rSphereInner=3; %Sphere radius
rSphereOuter=2.075; %Sphere radius
numRefine=3; %Number of refinement steps for geoSphere

smoothParInner.Method='LAP'; %Laplacian smoothing

smoothParOuter.Method='HC'; %Humphreys-Classes smoothing

controlParFaomWrap.foamThickness=[]; %Empty uses default which is mean edgelength based

Create inner shape

% Create a sphere surface model
[Fs,Vs,~]=geoSphere(numRefine,rSphereInner); %Geodesic sphere triangulation

% Create an icosahedron surface model
[Vi,~]=platonic_solid(4,rSphereInner); %Get icosahedron

% Compute distances from the sphere to the icosahedron vertices

% Adjust distance
D=D.^2; %Square distance
D=D-min(D(:)); D=D./max(D(:)); %Normalize [0 1]
D=D.*rSphereInner; %Multiply by radius [0 rSphere]

% Morph shape of sphere using distance data
[Ts,Ps,Rs] = cart2sph(Vs(:,1),Vs(:,2),Vs(:,3)); %Get spherical coordinates
Rs_n=Rs-2*1/2.5*D; %Create adjusted radius
[Vs(:,1),Vs(:,2),Vs(:,3)] = sph2cart(Ts,Ps,Rs_n); %Convert back to Cartesian coordinates
[Vs]=patchSmooth(Fs,Vs,[],smoothParInner); %Smoothen the result

%Compute the dual of the triangulation

Create rotation matrix

A rotation matrix is created to reorient the shapes such that one of the icosahedron vertices points at the camera

n1=vecnormalize(Vi(1,:)); %Position vector 1 normalized to be axis 1
n2=vecnormalize(Vi(2,:)); %Position vector 2 normalized
n3=vecnormalize(cross(n1,n2)); %Axis 3 created as orthogonal to both n1 and n2
n2=vecnormalize(cross(n1,n3)); %Form axis 2 as orthogonal to both n1 and n3
Q=[n1; n2; n3]; %Create rotation matrix

Create outer shape

First create an icosahedron, refine it, and compute the structure that wraps the surface.

% Create refine icosahedron surface
[Vi,Fi]=platonic_solid(4,rSphereOuter); %Get icosahedron
[Fi,Vi,C,indIni]=triPolyDualRefine(Fi,Vi); %Refine the icosahedron

% Wrap surface

% Keep only subset of surface components
[F_outer,V_outer]=subtri(F_outer,V_outer,1); %Refine 1 iteration

%Smoothen to round the shape

Rotate geometries


Visualizaing surface models

A slightly messy plot (light is used twice to produce a bright look). Use the export figure widget to export images.

hf=cFigure; hold on;

%Plot inner surface
for q=1:1:numel(F_inner)

%Plot outer surface

axisGeom; axis off;
camlight headlight;
camlight headlight;
lighting flat;


Kevin Mattheus Moerman,

GIBBON footer text


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

Copyright (C) 2006-2020 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