[37] | 1 | function [M, pts] = unoccluded_motion(nframes,npoints,frot,ftrans)
|
---|
| 2 |
|
---|
| 3 | % To generate this, we'll consider a very simple situation in which the motion
|
---|
| 4 | % is constant, and the points are randomly chosen from within a cube.
|
---|
| 5 | % the cube in between 0 and 1 in each dimension, so the image will be
|
---|
| 6 | % roughly of size 1x1.
|
---|
| 7 | % We assume that the key variable is the amount of rotation in depth,
|
---|
| 8 | % so we'll make the in-plane rotation constant so that it adds up to
|
---|
| 9 | % ninety degrees, and the translation constant,
|
---|
| 10 | % in a random direction.
|
---|
| 11 |
|
---|
| 12 | M = [];
|
---|
| 13 | translation_mag = ftrans/(nframes-1);
|
---|
| 14 | ip_rot = (pi/2)/(nframes-1);
|
---|
| 15 | op_rot = (2*pi*frot)/(nframes-1);
|
---|
| 16 |
|
---|
| 17 | pts = rand(4,npoints);
|
---|
| 18 | pts(4,:) = ones(1,npoints);
|
---|
| 19 | % points have x,y,z coordinates, and a 1 in the 4th row for translation.
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | depth_axis = 2*pi*rand(1);
|
---|
| 23 | %depth_axis = 0;
|
---|
| 24 | translation_dir = 2*pi*rand(1);
|
---|
| 25 | translation_vec = translation_mag*[cos(translation_dir), sin(translation_dir),0];
|
---|
| 26 |
|
---|
| 27 | rpts1 = rotate_z_axis(pts,depth_axis);
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | for fnum=0:nframes-1
|
---|
| 31 | rpts2 = rotate_x_axis(rpts1,op_rot*fnum);
|
---|
| 32 | rpts3 = rotate_z_axis(rpts2,-depth_axis);
|
---|
| 33 | rpts4 = rotate_z_axis(rpts3,ip_rot*fnum); |
---|
| 34 | rpts5 = translate(rpts4,fnum*translation_vec);
|
---|
| 35 | M = [M',rpts5(1:2,:)']';
|
---|
| 36 | end
|
---|
| 37 |
|
---|