PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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