%% Demo: parameterizing a line
% first, a random reference point and direction
r0 = rand(3,1);
v = rand(3,1);

ms = 'markersize';


clf;
plot3(r0(1), r0(2), r0(3), 'r*', ms, 20)  % reference point
hold on;
plot3([0 r0(1)], ...
      [0 r0(2)], ...
      [0 r0(3)], 'r-')  % line-segment from origin to ref pt

xlabel('x'); ylabel('y'); zlabel('z')

% now draw linesegment and circle in the direction of v
t = 1;
r = r0 + t*v;
plot3(r(1), r(2), r(3), 'bo', ms, 20)
plot3([r0(1) r(1)], ...
      [r0(2) r(2)], ...
      [r0(3) r(3)], 'k-')

pause

% draw random points on the line
for i=1:500
  t = 2*rand-1;
  r = r0 + t*v;
  plot3(r(1), r(2), r(3), 'g.')
  pause(0)
end
