-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalphaFcn.m
More file actions
27 lines (17 loc) · 840 Bytes
/
alphaFcn.m
File metadata and controls
27 lines (17 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [alpha,ecc] = alphaFcn(C,normalVector,indenterType)
% Discretization for numerical integration
numSteps = 720;%0.5*60;
angleVec = linspace(0,180-180/numSteps,numSteps);
hSave = hIntegralVlassak(0,C,normalVector,angleVec,0);
[~,mIdx] = max(hSave);
% Determine the major axis of the ellipse.
hSaveOld = [hSave ; hSave]; % Double the hSave for the range (180 , 360]
hSave = hSaveOld(mIdx:mod((mIdx+numSteps-1),length(hSaveOld)));
if strcmp(indenterType,'Cone')
costFcn = @(XIN) costFcnPyr(XIN,angleVec,hSave);
ecc = fminbnd(costFcn,0,1);
elseif strcmp(indenterType,'Sphere')
costFcn = @(XIN) trapz(deg2rad(angleVec),hSave' ./ sqrt(1 - XIN(1)^2.*cosd(angleVec).^2))*sqrt(2-XIN(1)^2);
ecc = fminbnd(costFcn,0,1);
end
alpha = trapz(deg2rad(angleVec),hSave' ./ sqrt(1 - ecc^2.*cosd(angleVec).^2));