%% Demo: random points on a line in 3D

a = [1 2 6];
%a = -3*a
q = [1 1 1];
%q = [2 3 7]

figure(1); clf;
lw = 'linewidth';
plot3([0 q(1)], [0 q(2)], [0 q(3)], 'b-', lw, 3);
hold on
plot3([0 a(1)]+q(1), ...
      [0 a(2)]+q(2), ...
      [0 a(3)]+q(3), 'r-', lw, 3);

axis equal
grid on

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

for i=1:1000
  s = 4*rand()-2;
  x = q + s*a;
  plot3(x(1), x(2), x(3), 'k.', lw, 4)
  drawnow()
end
