%PlotTraj
%Script to plot the  trajectories for a simulation (in memory)
%Daniel Fraser June 2001
data=d;
NumTraj=10;
NumRef=75;
%figure
if (size(data.Field,2)>=NumTraj)
  for i = 1:NumTraj
     hold on;
     plot3(data.Field{i}(1,:),data.Field{i}(2,:),data.Field{i}(3,:));
  end
end
if (size(data.SurfaceO,2)>0)
  plot3(data.SurfaceO(1,1:NumTraj),...
  data.SurfaceO(2,1:NumTraj),...
  data.SurfaceO(3,1:NumTraj),'ro');
end
if (size(data.SurfaceR,2)>0)
  hold on;
  plot3(data.SurfaceR(1,1:NumRef),...
  data.SurfaceR(2,1:NumRef),...
  data.SurfaceR(3,1:NumRef),'go');
end
xlabel('X (mm)');
ylabel('Y (mm)');
zlabel('Z (mm)');
title([num2str(NumTraj) ' photon trajectories']);

if ~isfield(m,'BoundaryShape')
  m.BoundaryShape=1;   %the default boundary for backward compatablity
end

if m.BoundaryShape==1 
  [X,Y,Z] = sphere(40);
  X = m.radial_size*X;
  Y = m.radial_size*Y;
  Z = m.radial_size*Z;
  plot3(X,Y,Z,'k:','LineWidth',0.1,'MarkerSize',0.1) %actualy I think the smallest posible is 1
end
