Line | |
---|
1 | % nfi2r Computes rotation matrix, axis of rotation and the angle are given |
---|
2 | % |
---|
3 | % R = nfi2r(n,fi) |
---|
4 | % Inputs: |
---|
5 | % n[3x1] ... axis of rotation (vector of direction) |
---|
6 | % fi[rad] ... angle of rotation (counter clockwise) |
---|
7 | % Return: |
---|
8 | % R ... rotation matrix |
---|
9 | % |
---|
10 | % T. Svoboda, 3/1998, CMP Prague |
---|
11 | % |
---|
12 | % $Id: nfi2r.m,v 1.1 2003/07/03 15:38:40 svoboda Exp $ |
---|
13 | |
---|
14 | % page 203 of the book: |
---|
15 | % @BOOK{Kanatani90, |
---|
16 | % AUTHOR = {Kanatani, Kenichi}, |
---|
17 | % PUBLISHER = {Springer-{V}erlag}, |
---|
18 | % TITLE = {Group-{T}heoretical Methods in Image Understanding}, |
---|
19 | % YEAR = {1990}, |
---|
20 | % HARDCOPY = { CMPlib.book.BC14 }, |
---|
21 | % SIGNATURE = {X-copy}, |
---|
22 | % ISSN_ISBN = {3-540-51263-5}, |
---|
23 | % |
---|
24 | |
---|
25 | function R = nfi2r(n,fi) |
---|
26 | |
---|
27 | n = n./norm(n,2); |
---|
28 | cfi = cos(fi); |
---|
29 | sfi = sin(fi); |
---|
30 | |
---|
31 | R(1,1:3) = [ cfi+n(1)^2*(1-cfi), n(1)*n(2)*(1-cfi)-n(3)*sfi, n(1)*n(3)*(1-cfi)+n(2)*sfi ]; |
---|
32 | R(2,1:3) = [ n(1)*n(2)*(1-cfi)+n(3)*sfi, cfi+n(2)^2*(1-cfi), n(2)*n(3)*(1-cfi)-n(1)*sfi ]; |
---|
33 | R(3,1:3) = [ n(3)*n(1)*(1-cfi)-n(2)*sfi, n(3)*n(2)*(1-cfi)+n(1)*sfi, cfi+n(3)^2*(1-cfi) ]; |
---|
34 | |
---|
35 | R = R'; % due to reverse notation of Kanatani |
---|
36 | |
---|
37 | return |
---|
Note: See
TracBrowser
for help on using the repository browser.