/verify_vsf_lookup_table.m

http://github.com/gallamine/Photonator · Objective C · 40 lines · 27 code · 13 blank · 0 comment · 4 complexity · 9f8d4aeebe7ff485164ed9b2502f5b6b MD5 · raw file

  1. % Test the method for calculating scattering lengths and choosing values
  2. % from the VSF (volume scattering function) distribution
  3. num_photons = 1e6;
  4. inv_b = 1;
  5. [cdf_scatter,angle] = generate_scatter('measured','petzold_avg');
  6. rand_array = rand(num_photons,3); % generate a matrix for each photon with rand propogation, roll, and pitch
  7. rand_array(:,3) = rand_array(:,3).*2.*pi; %% Uniformly distributed over 0 -2Pi
  8. r = zeros(1,num_photons);
  9. theta = zeros(1,num_photons);
  10. % iterate over every single photon to calculate new position and
  11. % whether it was received or not.
  12. for i = 1:num_photons
  13. r(i) = -inv_b*log(rand_array(i,1)); % randomly generate optical path length
  14. %Generate scattering angle from beam spread function
  15. k = 1;
  16. while rand_array(i,2) > cdf_scatter(k)
  17. k = k+1;
  18. end
  19. theta(i) = angle(k);
  20. end
  21. hold on;
  22. figure(3);[N,X] = hist(r,100);
  23. plot(X,N./N(1));
  24. figure(4);[N,X] = hist(theta,500);
  25. plot(X,N./N(1));
  26. figure(5);[N,X] = hist(rand_array(:,3),360);
  27. plot(X,N./N(1));