2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 // Copyright (C) DIGITEO - 2010 - Allan CORNET
6 // This file is distributed under the same license as the Scilab package.
11 function demo_riemann()
20 // =========================================================================
21 my_handle = scf(100001);
22 clf(my_handle, "reset");
24 // Add "see code" menu item
25 // =========================================================================
26 demo_viewCode(SCI+"/modules/graphics/demos/anim/anim8/anim8.sci");
29 // =========================================================================
30 my_handle.immediate_drawing = "off";
33 // =========================================================================
34 my_handle.color_map = rainbowcolormap(128);
37 // =========================================================================
38 [z,s] = cplxroot(4,35);
41 // =========================================================================
42 cplxmap(z,s,163,69); //draw
44 // Adjust some graphical parameters
45 // =========================================================================
49 // my_handle.axes_size = [ 600 650 ];
51 my_handle.background = -2; // white
52 my_axe.background = -1; // gray
53 my_axe.foreground = 14; // white
54 my_fac3d.color_mode = 1; // no lines
57 // =========================================================================
58 my_handle.immediate_drawing = "on";
61 // =========================================================================
63 my_quit_button = uicontrol( ..
64 "parent" , my_handle, ..
65 "style" , "pushbutton", ..
67 "units" , "pixels", ..
68 "position" , [ 350 15 100 30 ], ..
69 "background" , [0.9 0.9 0.9], ..
70 "Relief" , "groove", ..
71 "callback" , "quit_riemann", ..
72 "callback_type" , 10, ..
73 "tag" , "pushbutton_bac" ..
76 my_pause_button = uicontrol( ..
77 "parent" , my_handle, ..
78 "style" , "pushbutton", ..
79 "string" , "PAUSE", ..
80 "units" , "pixels", ..
81 "position" , [ 150 15 100 30 ], ..
82 "background" , [0.9 0.9 0.9], ..
83 "Relief" , "groove", ..
84 "callback_type" , 10, ..
85 "callback" , "pause_riemann", ..
86 "tag" , "my_pause_button" ..
89 my_play_button = uicontrol( ..
90 "parent" , my_handle, ..
91 "style" , "pushbutton", ..
93 "units" , "pixels", ..
94 "position" , [ 150 15 100 30 ], ..
95 "background" , [0.9 0.9 0.9], ..
96 "callback" , "play_riemann", ..
97 "callback_type" , 10, ..
98 "Relief" , "groove", ..
100 "tag" , "my_play_button" ..
105 my_rotation_dir = [0 1];
110 if quit_var == 1 then
111 if isHandleExistAndValid("my_handle") then
117 if pause_var == 1 & ~isHandleExistAndValid("my_handle") then
123 if isHandleExistAndValid("my_pause_button") & ..
124 isHandleExistAndValid("my_pause_button") & ..
125 isHandleExistAndValid("my_quit_button") & ..
126 isHandleExistAndValid("my_handle") then
128 if pause_var == 1 then
129 my_play_button.visible = "on";
130 my_pause_button.visible = "off";
133 if pause_var == 0 then
134 if my_pause_button.visible == "off" then
135 my_play_button.visible = "off";
136 my_pause_button.visible = "on";
139 my_axe.rotation_angles = my_axe.rotation_angles + my_rotation_dir;
140 my_counter = my_counter + 1;
143 if modulo(my_counter,720) == 0 then
144 my_rotation_dir = [0 1];
145 elseif modulo(my_counter,360) == 0 then
146 my_rotation_dir = [1 0];
156 function cplxmap(z, w, varargin)
158 //cplxmap(z,w,T,A,leg,flags,ebox)
159 //cplxmap Plot a function of a complex variable.
168 my_color_map = my_handle.color_map;
169 ncols = size(my_color_map, "r");
171 [X, Y, U] = nf3d(x, y, u);
172 [X, Y, V] = nf3d(x, y, v);
173 Colors = sum(V, "r");
174 Colors = Colors - min(Colors);
175 Colors = int((ncols-1) * Colors / max(Colors) + 1);
177 plot3d(X, Y, list(U, Colors), varargin(:));
181 function [z, s] = cplxroot(n, m)
183 //cplxroot(n,m,T,A,leg,flags,ebox)
184 //CPLXROOT Riemann surface for the n-th root.
185 // CPLXROOT(n) renders the Riemann surface for the n-th root.
186 // CPLXROOT, by itself, renders the Riemann surface for the cube root.
187 // CPLXROOT(n,m) uses an m-by-m grid. Default m = 20.
188 // Use polar coordinates, (r,theta).
189 // Cover the unit disc n times.
192 [lhs, rhs] = argn(0);
194 if rhs < 1, n = 3; end
195 if rhs < 2, m = 20; end
198 theta = - %pi*(-n*m:n*m)/m;
199 z = r * exp(%i*theta);
200 s = r.^(1/n) * exp(%i * theta/n);
204 function quit_riemann
209 function pause_riemann
214 function play_riemann
219 function bOK = isHandleExistAndValid(handleName)
220 bOK = is_handle_valid(evstr(handleName)) & (type(evstr(handleName)) == 9) & exists(handleName);