-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmisorientation.m
More file actions
36 lines (26 loc) · 813 Bytes
/
misorientation.m
File metadata and controls
36 lines (26 loc) · 813 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
28
29
30
31
32
33
34
35
36
function misorient = misorientation(euler1, euler2)
% To Compute misorientation between euler angles
%%% Inputs:
% Euler angles are in Degree.
%%% Outputs:
% misorientation in Degree.
% numerical tolerance threshold
threshold = 1e-6; % to deal with single precision error
% compute misorientation
quat1 = euler2quat(euler1*pi/180);
quat2 = euler2quat(euler2*pi/180);
qdot = dot(quat1,quat2);
% if qdot>1 (euler1 and euler2 are the same angle, numerical error)
if qdot>1
if qdot-1<threshold
misorient = 0;
return
else
% issue beyond numerical error
warning('dp > 1+eps');
% continue calcs, which will give complex numbers
end
end
% if qdot~=1, continue...
misorient = 2*acosd(qdot);
misorient = min(misorient,360-misorient); % put in range 0.6.18