Rev | Line | |
---|
[37] | 1 | function S = random_motion(n)
|
---|
| 2 | % We will produce an 2nx4 matrix that describes a random motion. Each row of
|
---|
| 3 | % S is (r1 r2 r3 t) where t is a translation and (r1 r2 r3) is a component of
|
---|
| 4 | % rotation. An odd row and the following even row must have orthonormal
|
---|
| 5 | % rotation vectors.
|
---|
| 6 | S = [];
|
---|
| 7 | for i = 1:n
|
---|
| 8 | S = [S; one_random_rotation];
|
---|
| 9 | end
|
---|
| 10 | S = [S,rand(2*n,1)];
|
---|
| 11 |
|
---|
| 12 | function S = one_random_rotation()
|
---|
| 13 | r1 = random_normal;
|
---|
| 14 | r2 = random_normal;
|
---|
| 15 | r2p = r2 - sum(r2.*r1)*r1;
|
---|
| 16 | % r2p is projected into the plane normal to r1. It's no longer a unit vector.
|
---|
| 17 | r2pn=r2p./(sqrt(sum(r2p.*r2p)));
|
---|
| 18 | S = [r1'; r2pn']; |
---|
Note: See
TracBrowser
for help on using the repository browser.