Advertisement
dmkozyrev

sputnik.m

Jun 2nd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. function example
  2.   r = 1;
  3.   i = pi/9;
  4.   Omega = pi/6;
  5.   omega = pi/3;
  6.  
  7.   cos_Omega = cos(Omega);
  8.   sin_Omega = sin(Omega);
  9.  
  10. %  cos_omega = cos(omega);
  11. %  sin_omega = sin(omega);
  12.  
  13.   cos_i = cos(i);
  14.   sin_i = sin(i);
  15.  
  16.   a = 0;
  17.   b = 2*pi;
  18.   t = [a:(b-a)/180:b];
  19.  
  20.  
  21.  
  22.   x = y = z = zeros(1, length(t));
  23.  
  24.  
  25.   [X, Y, Z] = sphere(25);
  26.   mesh(X*0.7, Y*0.7, Z*0.7);
  27.   axis ([-1 1 -1 1 -1 1]);
  28.   grid on
  29.   hold on
  30.  
  31.  
  32.   first = true;
  33.   sputnik = 0;
  34.  
  35.   k = 1;
  36.   x1 = r*(cos_Omega*cos(t(k)+omega)-sin_Omega*sin(t(k)+omega)*cos_i);
  37.   y1 = r*(sin_Omega*cos(t(k)+omega)+cos_Omega*sin(t(k)+omega)*cos_i);
  38.   z1 = r*sin(t(k)+omega)*sin_i;
  39.    
  40.   for k = 2:length(t)
  41.     x2 = r*(cos_Omega*cos(t(k)+omega)-sin_Omega*sin(t(k)+omega)*cos_i);
  42.     y2 = r*(sin_Omega*cos(t(k)+omega)+cos_Omega*sin(t(k)+omega)*cos_i);
  43.     z2 = r*sin(t(k)+omega)*sin_i;
  44.    
  45.     plot3([x1, x2], [y1, y2], [z1, z2], 'r');
  46.    
  47.     x1 = x2;
  48.     y1 = y2;
  49.     z1 = z2;
  50.    
  51.    
  52.       if (~first)
  53.         delete(sputnik);
  54.       else
  55.         first = false;
  56.       end
  57.      
  58.       [X, Y, Z] = sphere(6);
  59.       R = 0.05;
  60.       X = x1 + R * X;
  61.       Y = y1 + R * Y;
  62.       Z = z1 + R * Z;
  63.       sputnik = surf(X, Y, Z);
  64.       pause(0.001);
  65.   end
  66.  
  67.  
  68.  
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement