Line | |
---|
1 | % By Philip Torr 2002
|
---|
2 | % copyright Microsoft Corp.
|
---|
3 | function [a,b] = torr_unit2sphere(rot_axis)
|
---|
4 |
|
---|
5 | % %convert rot_axis to spherical coords
|
---|
6 | % sin a sin b
|
---|
7 | % sin a cos b
|
---|
8 | % cos a
|
---|
9 | rot_axis = rot_axis/norm(rot_axis);
|
---|
10 |
|
---|
11 | %normalize so second coordinate + ve
|
---|
12 | %rot_axis = rot_axis * sign(rot_axis(2));
|
---|
13 |
|
---|
14 | a = acos(rot_axis(3));
|
---|
15 | %b = atan(rot_axis(1)/rot_axis(2));
|
---|
16 | b = acos(rot_axis(2)/sin(a));
|
---|
17 |
|
---|
18 | %need to sort the signs out:
|
---|
19 | % %there are two solutions for a
|
---|
20 | % a2 = -a;
|
---|
21 | % b2 = -b;
|
---|
22 |
|
---|
23 |
|
---|
24 | if abs(rot_axis(1) - sin(a) * sin(b)) < 0.000001
|
---|
25 | return
|
---|
26 | else
|
---|
27 | b = -b;
|
---|
28 | end
|
---|
29 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.