-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjpa_calcYAxesRotation.m
More file actions
49 lines (46 loc) · 1.31 KB
/
jpa_calcYAxesRotation.m
File metadata and controls
49 lines (46 loc) · 1.31 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
function rotateDegree = jpa_calcYAxesRotation(coord)
% Function that calculates y-axis-rotation from 3D Coord 0/0/0
% to given coords
%
% Syntax:
% rotateDegree = jpa_calcYAxesRotation(coord)
%
% Inputs:
% coord - Coords where to turn y-Axis to
%
% Outputs:
% rotateDegree - Degree
%
% Example:
% rotateDegree = jpa_calcYAxesRotation([-20 10 50])
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also:
% Author: Jan Albrecht
% Work address:
% email: jan-philipp.albrecht@charite.de, j.p.albrecht@fu-berlin.de
% Website:
% Sep 2015; Last revision: 13-Okt-2015
%------------- BEGIN CODE --------------
% calculate
if coord(1,2) == 0
value1 = 0;
else
value1 = coord(1,3)/coord(1,2);
end
if sign(coord(1,1)) < 0 && sign(coord(1,3)) < 0 % both negative
rotateDegree = abs(round(atand(value1)));
else if sign(coord(1,1)) < 0 % first negative
rotateDegree = -1 * abs(round(atand(value1)));
else if sign(coord(1,3)) < 0 % third negative
rotateDegree = abs(round(atand(value1)));
else % both positive
rotateDegree = -1 * abs(round(atand(value1)));
end
end
end
end
%------------- END CODE --------------