0001 classdef testMptBugs < TestCase
0002 methods
0003 function self = testMptBugs(name)
0004 self = self@TestCase(name);
0005 end
0006
0007 function testVolumeOnSphere(self)
0008
0009
0010 n = 15;
0011
0012 phi = 0:(pi/n):(pi-pi/n/2);
0013 theta = 0:(pi/n):(2*pi-pi/n/2);
0014
0015 phi = ones(2*n,1)*phi;
0016 theta = theta'*ones(1,n);
0017
0018 X = sin(theta).*cos(phi);
0019 Y = sin(theta).*sin(phi);
0020 Z = cos(theta);
0021
0022 CH(:,1) = X(:);
0023 CH(:,2) = Y(:);
0024 CH(:,3) = Z(:);
0025
0026 PT = polytope(CH);
0027 extremePT = extreme(PT);
0028
0029 assertElementsAlmostEqual(...
0030 extremePT(:,1).^2+extremePT(:,2).^2+extremePT(:,3).^2,...
0031 extremePT(:,1)*0+1, 'absolute', 1e-10, ...
0032 'Extreme points should be on the unit sphere')
0033
0034 [K, volumeConvHull] = convhulln(CH);
0035 volumeMpt = volume(PT);
0036
0037
0038 assertElementsAlmostEqual(volumeMpt, 4/3*pi, ...
0039 'absolute', 1e-1, ...
0040 ['Mpt error with the volume much larger than possible. ' ...
0041 'For reference volume from convexhulln:' ...
0042 num2str(volumeConvHull)])
0043 end
0044
0045 end
0046 end