public Spiralframe() { Size = new Size(form_width, form_height); MaximumSize = maxframesize; MinimumSize = minframesize; Text = "r = sin(4t) By Michael Rozsypal"; BackColor = Color.Pink; archimedes = new Spiral_algorithms(); t = 0.0; //possible importance to change for calculation //Declare variables for the spiral function r = a + b*t. // trying to make r = sin(4t) a = 1 b = 4 // x(t) = sin(4t)cos(t) y(t) = sin(4t)sin(t) // derivatives: 'x = 4cos(4t)cos(t)-sin(4t)sin(t) 'y = 4cos(4t)sin(t)+sin(4t)cos(t) x = (Math.Sin(b_coefficient * t)) * System.Math.Cos(t); y = (Math.Sin(b_coefficient * t)) * System.Math.Sin(t); start_button.Text = "Start Spiral"; start_button.Size = new Size(80, 22); start_button.Location = location_of_start_button; start_button.BackColor = Color.LimeGreen; exit_button.Text = "Exit"; exit_button.Size = new Size(80, 22); exit_button.Location = location_of_exit_button; exit_button.BackColor = Color.LimeGreen; graphic_area_refresh_clock.Enabled = false; graphic_area_refresh_clock.Elapsed += new ElapsedEventHandler(Update_the_graphic_area); spiral_clock.Enabled = false; spiral_clock.Elapsed += new ElapsedEventHandler(Update_the_position_of_the_spiral); DoubleBuffered = true; pointer_to_graphic_surface = Graphics.FromImage(pointer_to_bitmap_in_memory); initialize_bitmap(); Controls.Add(start_button); start_button.Click += new EventHandler(Manage_spiral_clock); Controls.Add(exit_button); exit_button.Click += new EventHandler(Stoprun); Start_graphic_clock(refresh_rate); System.Console.WriteLine("The constructor Spiralframe has completed its job."); }
double elapsed_time_between_updates_of_spiral_coordinates_rounded_seconds; //Units are whole seconds //Define the constructor of this class. public Spiralframe(uint width) { //Set the initial size of this form. form_width = (int)width; form_height = (int)width * 9 / 16; graphic_area_height = form_height - control_region_height; Size formsize = new Size(form_width, form_height); Size = formsize; MaximumSize = formsize; //The user cannot re-size the main window. MinimumSize = formsize; //Set the location of the polar origen in C# coordinates. polar_origen_x = (int)System.Math.Round(form_width / 2.0); polar_origen_y = (int)System.Math.Round(graphic_area_height / 2.0); //Set the location of buttons location_of_start_button = new Point(40, form_height - control_region_height + 10); location_of_exit_button = new Point(form_width - 40 - 80, form_height - control_region_height + 10); //Set the title of this user interface. Text = "Archimedean Spiral Traced by a Particle Moving at Constant Linear Velocity"; //Set the initial background color of this form. BackColor = Color.Pink; //Instantiate the collection of supporting algorithms archimedes = new Spiral_algorithms(); //Set initial values for the spiral in a standard mathematical cartesian coordinate system (no scaling at this time) t = 0.0; x = (initial_radius + b_coefficient * t) * System.Math.Cos(t); y = (initial_radius + b_coefficient * t) * System.Math.Sin(t); //Prepare the buttons start_button.Text = "Start Spiral"; start_button.Size = new Size(80, 22); start_button.Location = location_of_start_button; start_button.BackColor = Color.LimeGreen; exit_button.Text = "Exit"; exit_button.Size = new Size(80, 22); exit_button.Location = location_of_exit_button; exit_button.BackColor = Color.LimeGreen; //Set properties of the label accumulated_time accumulated_time.Size = new Size(44, 14); accumulated_time.Location = new Point(40 + 80 + 10, graphic_area_height + 18); accumulated_time.Text = "0000.0"; accumulated_time_annotation.Size = new Size(138, 14); accumulated_time_annotation.Location = new Point(40 + 80 + 10, graphic_area_height + 4); ///accumulated_time_annotation.Color = Color.Blue; accumulated_time_annotation.Text = "Elapsed time (seconds)"; //Prepare the refresh clock graphic_area_refresh_clock.Enabled = false; graphic_area_refresh_clock.Elapsed += new ElapsedEventHandler(Update_the_graphic_area); //Prepare the spiral clock spiral_clock.Enabled = false; spiral_clock.Elapsed += new ElapsedEventHandler(Update_the_position_of_the_spiral); //Use extra memory to make a smooth animation. DoubleBuffered = true; //Initialize the pointer used to write onto the bitmap stored in memory. pointer_to_bitmap_in_memory = new Bitmap(form_width, form_height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); pointer_to_graphic_surface = Graphics.FromImage(pointer_to_bitmap_in_memory); initialize_bitmap(); //Make buttons visible and attach buttons to functions Controls.Add(start_button); start_button.Click += new EventHandler(Manage_spiral_clock); //How does Start_spiral_clock receive the update rate? Controls.Add(exit_button); exit_button.Click += new EventHandler(Stoprun); //Make the labels visible Controls.Add(accumulated_time); Controls.Add(accumulated_time_annotation); //Start refresh clock running Start_graphic_clock(refresh_rate); //Make sure this graphical window appears in the center of the monitor. CenterToScreen(); System.Console.WriteLine("The constructor Spiralframe has completed its job."); } //End of constructor of Spiralframe class.
//Define the constructor of this class. public Spiralframe() { //Set the initial size of this form. Size = new Size(form_width, form_height); MaximumSize = maxframesize; MinimumSize = minframesize; //Set the title of this user interface. Text = "r = sin(4t) By Michael Rozsypal"; //Give feedback to the programmer. System.Console.WriteLine("form_width = {0}, form_height = {1}.", form_width, form_height); System.Console.WriteLine("polar_origen_x = {0}, polar_origen_y = {1}.", polar_origen_x, polar_origen_y); //Set the initial background color of this form. BackColor = Color.Pink; //Instantiate the collection of supporting algorithms archimedes = new Spiral_algorithms(); //Set initial values for the spiral in a standard mathematical cartesian coordinate system (no scaling at this time) t = 0.0; //possible importance to change for calculation //Declare variables for the spiral function r = a + b*t. // trying to make r = sin(4t) a = 1 b = 4 // x(t) = sin(4t)cos(t) y(t) = sin(4t)sin(t) // derivatives: 'x = 4cos(4t)cos(t)-sin(4t)sin(t) 'y = 4cos(4t)sin(t)+sin(4t)cos(t) x = (Math.Sin(b_coefficient * t)) * System.Math.Cos(t); y = (Math.Sin(b_coefficient * t)) * System.Math.Sin(t); //Prepare the buttons start_button.Text = "Start Spiral"; start_button.Size = new Size(80, 22); start_button.Location = location_of_start_button; start_button.BackColor = Color.LimeGreen; exit_button.Text = "Exit"; exit_button.Size = new Size(80, 22); exit_button.Location = location_of_exit_button; exit_button.BackColor = Color.LimeGreen; //Prepare the refresh clock graphic_area_refresh_clock.Enabled = false; graphic_area_refresh_clock.Elapsed += new ElapsedEventHandler(Update_the_graphic_area); //Prepare the spiral clock spiral_clock.Enabled = false; spiral_clock.Elapsed += new ElapsedEventHandler(Update_the_position_of_the_spiral); //Use extra memory to make a smooth animation. DoubleBuffered = true; //Initialize the pointer used to write onto the bitmap stored in memory. pointer_to_graphic_surface = Graphics.FromImage(pointer_to_bitmap_in_memory); initialize_bitmap(); //Make buttons visible and attach buttons to functions Controls.Add(start_button); start_button.Click += new EventHandler(Manage_spiral_clock); //How does Start_spiral_clock receive the update rate? Controls.Add(exit_button); exit_button.Click += new EventHandler(Stoprun); //Start refresh clock running Start_graphic_clock(refresh_rate); System.Console.WriteLine("The constructor Spiralframe has completed its job."); } //End of constructor of Spiralframe class.