Пример #1
0
        //,Physic.Grid myGrid,System.Collections.ArrayList alData)
        void Draw_Field_Vectors(System.Drawing.Graphics myGraphics)
        {
            if (get_mode()==0)
            {
                Physic.Electrostatic_field E_max = new Physic.Electrostatic_field();
                E_max.set_x(60);

                foreach (DefaultNamespace.Data myData in alDatas.Data)
                {
                    Physic.Position pt = myData.position;
                    Physic.Electrostatic_field E = myData.E;

                    Math.Vector_draw myVector = new Math.Vector_draw();
                    myVector.position_start.set_x(pt.get_x());
                    myVector.position_start.set_y(pt.get_y());
                    myVector.position_end.set_x(pt.get_x()+E.get_x());
                    myVector.position_end.set_y(pt.get_y()+E.get_y());

                    if (this.mnuOptionsUseColors.Checked)
                    {
                        Physic.Color myColor = new Physic.Color();
                        myVector.color = myColor.color("step",E.norm,0,E_max.norm);
                    }
                    else
                    {
                        myVector.color = System.Drawing.Color.White;
                    }

                        myVector.Draw(myGraphics);
                }
            }
            else if (get_mode()==1)
            {
                Physic.Magnetostatic_field B_max = new Physic.Magnetostatic_field();
                B_max.set_x(60);

                foreach (DefaultNamespace.Data myData in alDatas.Data)
                {
                    Physic.Position pt = myData.position;
                    Physic.Magnetostatic_field B = myData.B;

                    Math.Vector_draw myVector = new Math.Vector_draw();
                    myVector.position_start.set_x(pt.get_x());
                    myVector.position_start.set_y(pt.get_y());
                    myVector.position_end.set_x(pt.get_x()+B.get_x());
                    myVector.position_end.set_y(pt.get_y()+B.get_y());

                    if (this.mnuOptionsUseColors.Checked)
                    {
                        Physic.Color myColor = new Physic.Color();
                        myVector.color = myColor.color("step",B.norm,0,B_max.norm);
                    }
                    else
                    {
                        myVector.color = System.Drawing.Color.White;
                    }

                        myVector.Draw(myGraphics);
                }
            }
        }
Пример #2
0
        void Draw_Field_Rectangles(System.Drawing.Graphics myGraphics)
        {
            if (get_mode()==0)
            {
            Physic.Electrostatic_field E_max = new Physic.Electrostatic_field();
            E_max.set_x(60);

            foreach (DefaultNamespace.Data myData in alDatas.Data)
            {
                Physic.Position pt = myData.position;
                Physic.Electrostatic_field E = myData.E;

                Rectangle_draw myRect = new Rectangle_draw();
                myRect.width = myGrid.get_space().get_x()/2;
                myRect.height = myGrid.get_space().get_y()/2;
                myRect.get_position().set_x(pt.get_x());
                myRect.get_position().set_y(pt.get_y());
                if (this.mnuOptionsUseColors.Checked)
                {
                    Physic.Color myColor = new Physic.Color();
                    myRect.color = myColor.color("step",E.norm,0,E_max.norm);
                }
                else
                {
                    myRect.color = System.Drawing.Color.White;
                }

                myRect.Draw(myGraphics);
            }
            }
        }
Пример #3
0
        //,Physic.Grid myGrid,System.Collections.ArrayList alData)
        void Draw_Field_Grains(System.Drawing.Graphics myGraphics)
        {
            if (this.mnuModeE.Checked==true)
            {
                Physic.Electrostatic_field E_max = new Physic.Electrostatic_field();
                E_max.set_x(60);

                foreach (DefaultNamespace.Data myData in alDatas.Data)
                {
                    Physic.Position pt = myData.position;
                    Physic.Electrostatic_field E = myData.E;

                    Physic.Grain_draw myGrain = new Physic.Grain_draw();
                    myGrain.len = (float) System.Math.Sqrt(myGrid.get_space().get_x()*myGrid.get_space().get_x() + myGrid.get_space().get_y()*myGrid.get_space().get_y()) / (float) System.Math.Sqrt(2);
                    myGrain.get_position().set_x(pt.get_x());
                    myGrain.get_position().set_y(pt.get_y());
                    myGrain.get_direction().set_x(E.get_x());
                    myGrain.get_direction().set_y(E.get_y());
                    if (this.mnuOptionsUseColors.Checked)
                    {
                        Physic.Color myColor = new Physic.Color();
                        myGrain.color = myColor.color("linear",E.norm,0,E_max.norm);
                    }
                    else
                    {
                        myGrain.color = System.Drawing.Color.White;
                    }

                    myGrain.Draw(myGraphics);
                }
            }
            else if (this.mnuModeB.Checked==true)
            {
                Physic.Magnetostatic_field B_max = new Physic.Magnetostatic_field();
                B_max.set_x(60);

                foreach (DefaultNamespace.Data myData in alDatas.Data)
                {
                    Physic.Position pt = myData.position;
                    Physic.Magnetostatic_field B = myData.B;

                    Physic.Grain_draw myGrain = new Physic.Grain_draw();
                    myGrain.len = (float) System.Math.Sqrt(myGrid.get_space().get_x()*myGrid.get_space().get_x() + myGrid.get_space().get_y()*myGrid.get_space().get_y()) / (float) System.Math.Sqrt(2);
                    myGrain.get_position().set_x(pt.get_x());
                    myGrain.get_position().set_y(pt.get_y());
                    myGrain.get_direction().set_x(B.get_x());
                    myGrain.get_direction().set_y(B.get_y());
                    if (this.mnuOptionsUseColors.Checked)
                    {
                        Physic.Color myColor = new Physic.Color();
                        myGrain.color = myColor.color("linear",B.norm,0,B_max.norm);
                    }
                    else
                    {
                        myGrain.color = System.Drawing.Color.White;
                    }

                    myGrain.Draw(myGraphics);
                }
            }
        }
Пример #4
0
        void Calculate_Datas()
        {
            foreach(Physic.Position pt in myGrid.get_positions())
            {
                Physic.Electrostatic_field E = new Physic.Electrostatic_field(pt);
                Physic.Electrostatic_potential V = new Physic.Electrostatic_potential(pt);
                Physic.Magnetostatic_field B = new Physic.Magnetostatic_field(pt);

                foreach (Physic.Charge chg in alCharges.Charge)
                {
                    Physic.Electrostatic_field E_tmp = new Physic.Electrostatic_field(chg,pt);
                    Physic.Magnetostatic_field B_tmp = new Physic.Magnetostatic_field(chg,pt);
                    E = E + E_tmp; // + is overload
                    B = B + B_tmp;

                    Physic.Electrostatic_potential V_tmp = new Physic.Electrostatic_potential(chg,pt);
                    V = V + V_tmp;
                }

                DefaultNamespace.Data myData = new DefaultNamespace.Data();
                myData.position = pt;
                myData.E = E;
                myData.V = V;
                myData.B = B;
                alDatas.Data.Add(myData);
            }
        }
        public Physic.Electrostatic_field real_to_screen(Physic.Electrostatic_field E_real)
        {
            Physic.Electrostatic_field E_screen = new Physic.Electrostatic_field();

            E_screen.set_x (
                real_to_screen(
                E1_real.get_x(),
                E1_screen.get_x(),
                E2_real.get_x(),
                E2_screen.get_x(),
                E_real.get_x())
                           );

            E_screen.set_y (
                real_to_screen(
                E1_real.get_y(),
                E1_screen.get_y(),
                E2_real.get_y(),
                E2_screen.get_y(),
                E_real.get_y())
                           );

            E_screen.set_z (
                real_to_screen(
                E1_real.get_z(),
                E1_screen.get_z(),
                E2_real.get_z(),
                E2_screen.get_z(),
                E_real.get_z())
                           );

            E_screen.apply_to.set_x (
                real_to_screen(
                E1_real.apply_to.get_x(),
                E1_screen.apply_to.get_x(),
                E2_real.apply_to.get_x(),
                E2_screen.apply_to.get_x(),
                E_real.apply_to.get_x())
                                    );

            E_screen.apply_to.set_y (
                real_to_screen(
                E1_real.apply_to.get_y(),
                E1_screen.apply_to.get_y(),
                E2_real.apply_to.get_y(),
                E2_screen.apply_to.get_y(),
                E_real.apply_to.get_y())
                                    );

            E_screen.apply_to.set_z (
                real_to_screen(
                E1_real.apply_to.get_z(),
                E1_screen.apply_to.get_z(),
                E2_real.apply_to.get_z(),
                E2_screen.apply_to.get_z(),
                E_real.apply_to.get_z())
                                    );

            return E_screen;
        }
        public Physic.Electrostatic_field screen_to_real(Physic.Electrostatic_field E_screen)
        {
            Physic.Electrostatic_field E_real = new Physic.Electrostatic_field();

            E_real.set_x (
                screen_to_real(
                E1_screen.get_x(),
                E1_real.get_x(),
                E2_screen.get_x(),
                E_real.get_x(),
                E_screen.get_x())
                         );

            E_real.set_y (
                screen_to_real(
                E1_screen.get_y(),
                E1_real.get_y(),
                E2_screen.get_y(),
                E_real.get_y(),
                E_screen.get_y())
                         );

            E_real.set_z (
                screen_to_real(
                E1_screen.get_z(),
                E1_real.get_z(),
                E2_screen.get_z(),
                E_real.get_z(),
                E_screen.get_z())
                         );

            E_real.apply_to.set_x (
                screen_to_real(
                E1_screen.apply_to.get_x(),
                E1_real.apply_to.get_x(),
                E2_screen.apply_to.get_x(),
                E_real.apply_to.get_x(),
                E_screen.apply_to.get_x())
                                  );

            E_real.apply_to.set_y (
                screen_to_real(
                E1_screen.apply_to.get_y(),
                E1_real.apply_to.get_y(),
                E2_screen.apply_to.get_y(),
                E_real.apply_to.get_y(),
                E_screen.apply_to.get_y())
                                  );

            E_real.apply_to.set_z (
                screen_to_real(
                E1_screen.apply_to.get_z(),
                E1_real.apply_to.get_z(),
                E2_screen.apply_to.get_z(),
                E_real.apply_to.get_z(),
                E_screen.apply_to.get_z())
                                  );

            return E_real;
        }