I found this tool great except for one thing that for me is not working. If we consider the code:

function exp
set(gcf,'Color',[0.95,0.95,0.95])
[X,Y,Z] = sphere(30);
mesh(X,Y,Z,'facecolor',[0.7 0.7 0.7],'edgecolor','none'); hold on;
alpha(.7);
A = [0,0,1]';
B = [1,0,0]';
v3 = cross(cross(A,B),A);
t = linspace(0,atan2(norm(cross(A,B)),dot(A,B)));
v = A*cos(t)+v3*sin(t);
plot3(v(1,:),v(2,:),v(3,:),'LineWidth',0.2,'Color',[0.3,0.3,0.3])
view([80, -40])
axis equal, hidden off,
hold off
axis off
plot2svg('exp.svg')
end

we see a sphere with a line drawn where one part lies in front of the sphere and another part lies behind the sphere (the figure has transparency). In the matlab figure there is disctintion of those two different parts on the line colors. In the svg file we saw that there is no distinction of colors, i.e., the color of the line is the same whatever the line is ahead or behind the sphere.

There is a way to create the svg file with different colors for the objects created in front and behind the sphere? Or to make the lines behind dotted?

convhulln is failing in minboundsphere if there are some points with the same XYZ. I have to run minboundsphere(unique(xyz,'rows')) to avoid convhulln crashing. Here is example:
minboundsphere([ 0.8726 0.4577 -0.1708
0.8761 0.4610 -0.1411
0.8761 0.4610 -0.1411
0.8761 0.4610 -0.1411
0.8761 0.4610 -0.1411
])

Hi Tom,
The problem is as you point out, that the insphere code uses a dot product to find the distance to each facet. Then it is a simple call to linprog, with one slack variable for each facet.
A similar idea for edges though trips up becasue each edge has two normals. So then the distance to each edge is now the sqrt of the sum of squares of a pair of dot products. While I can avoid the sqrt, such a formulation would involve quadratic equality constraints for each slack variable. Clearly this is not solvable by linprog, or even quadprog. Fmincon would be needed, so a bit more nasty of a problem using a similar formulation to the one in insphere. Certainly one could use the existing insphere code to find decent starting values for such an iterative solution, but it is still a bit more work.
I'll need to think if there is another scheme that might apply.
John

Hi John,
Thanks for this submission, it's helped me a lot with a problem I'm working on. I was wondering if the insphere function could be adapted to find the largest sphere bound within the edges of the polygon rather than the faces, as if the polygon were a cage with the sphere bulging through the hollow faces. I'm not too sure how to approach this as the edge normals are not defined in 3D.
Thanks,
Tom

Hi John, I sent you an e-mail to the electronic address provided on your Matlab profile. In that e-mail I attached a point cloud for which 'minboundsphere' fails almost consistently.

Comment only