コード例 #1
0
ファイル: Particle.cs プロジェクト: kevenv/orbitsim
 /// <summary>
 /// Create a particle using it's physical properties (Vector)
 /// </summary>
 /// <param name="position">Position vector</param>
 /// <param name="speed">Speed vector</param>
 /// <param name="mass">Mass</param>
 /// <param name="radius">Radius</param>
 /// <param name="color">Color</param>
 protected Particle(Vector2D position, Vector2D speed, double mass, int radius, Color color)
 {
     this.mass = mass;
     this.radius = radius;
     this.color = color;
     this.position = position;
     this.speed = speed;
 }
コード例 #2
0
ファイル: SimPanel.cs プロジェクト: kevenv/orbitsim
        public SimPanel(int Width, int Height)
        {
            InitializeComponent();
            DoubleBuffered = true;
            this.PreviewKeyDown += new PreviewKeyDownEventHandler(SimPanel_PreviewKeyDown);
            this.KeyDown += new KeyEventHandler(SimPanel_KeyDown);
            this.MouseClick += new MouseEventHandler(SimPanel_MouseClick);
            this.MouseDown += new MouseEventHandler(SimPanel_MouseDown);
            this.MouseUp += new MouseEventHandler(SimPanel_MouseUp);
            this.MouseMove += new MouseEventHandler(SimPanel_MouseMove);
            Focus();
            quit = false;
            space = new Space();
            //space.collisionMode = true;
            start();

            centerX = Width / 2;
            centerY = Height / 2;

            scale = 1;

            drawSpeedInfo = true;
            //randomColorMode = false;

            drawSpeedVector = false;
            mouseX = -1;
            mouseY = -1;
            draggedX = -1;
            draggedY = -1;
            drawSpeed = null;
            speed = null;

            //Put default values to the inbuild body
            mass = DEFAULT_MASS;
            radius = DEFAULT_RADIUS;
            color = DEFAULT_COLOR;
            star = false;

            initTimer();
        }
コード例 #3
0
ファイル: SimPanel.cs プロジェクト: kevenv/orbitsim
        void SimPanel_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //2nd point of the speed vector of the inbuild body
                draggedX = e.X;
                draggedY = e.Y;

                drawSpeed = new Vector2D(draggedX, draggedY);

                //Real speed of the inbuild body
                speed = new Vector2D(mouseX - e.X, mouseY - e.Y);
                speed = speed*mouseScale;
            }
        }
コード例 #4
0
ファイル: SimPanel.cs プロジェクト: kevenv/orbitsim
        void SimPanel_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //1st point of the speed vector of the inbuild body
                mouseX = e.X;
                mouseY = e.Y;
                draggedX = mouseX;
                draggedY = mouseY;

                drawSpeed = new Vector2D(mouseX, mouseY);
                speed = new Vector2D(0, 0);

                drawSpeedVector = true;

                //if (randomColorMode)
                //    color = ColorSelectorPanel.getRandomColor();
            }
            Focus();
        }