/divergence.m

http://github.com/gallamine/Photonator · Objective C · 40 lines · 31 code · 9 blank · 0 comment · 0 complexity · 621d5a43d15249ed31d952de623921e3 MD5 · raw file

  1. %%
  2. tic
  3. diverg = 0.001;
  4. thetaD = diverg.*rand(1,2e6); % uniform rand. dist over divergence ang.
  5. phiD = (2*pi).*rand(1,2e6); % uniform rand. dist over azmuthal angles
  6. beta = 90.*pi/180; % direction the transmitter is pointing (zenith)
  7. alpha = 90.*pi/180; % direction the transmitter is pointing (azmuth)
  8. x = cos(beta).*cos(theta)-sin(beta).*cos(phi).*sin(theta);
  9. y = sin(alpha).*sin(beta).*cos(theta)+(cos(alpha).*sin(phi)+sin(alpha).*cos(beta).*cos(phi)).*sin(theta);
  10. z = cos(alpha).*sin(beta).*cos(theta)+(-sin(alpha).*sin(phi)+cos(alpha).*cos(beta).*cos(phi)).*sin(theta);
  11. thetaF = atan2(sqrt(y.^2+z.^2),x);
  12. phiF = atan2(y,z);
  13. init_angle = 0; %theta
  14. init_angle2 = 0; % phi
  15. toc;
  16. %
  17. % scatter3(x,y,z);
  18. % hold on;
  19. % scatter3([1],[0],[0])
  20. %%
  21. %
  22. % syms alpha beta phi theta
  23. %
  24. % Rx_alpha = [1,0,0;0,cos(alpha),sin(alpha);0,-sin(alpha),cos(alpha)];
  25. % Ry_beta = [cos(beta),0,-sin(beta);0,1,0;sin(beta),0,cos(beta)];
  26. % Rx_phi = [1,0,0;0,cos(phi),sin(phi);0,-sin(phi),cos(phi)];
  27. % Ry_theta = [cos(theta),0,-sin(theta);0,1,0;sin(theta),0,cos(theta)];
  28. % init = [1;0;0];
  29. %
  30. % final = Rx_alpha*Ry_beta*Rx_phi*Ry_theta*init
  31. %%