Esempio n. 1
0
 private void RotateZAsync()
 {
     while (_rotating)
     {
         _tnet = Transformations.TranslateToOrigin(_scrnpts, _tnet);
         _tnet = Transformations.RotateOnZ(_tnet, .05);
         _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
         Thread.Sleep(5);
         CallRefreshToMainThread();
     }
 }
Esempio n. 2
0
        private void RestoreInitialImage()
        {
            //create the screen coordinates:
            // scrnpts = vertices*ctrans
            if (_gooddata)
            {
                Transformations.SetIdentity(_tnet, 4, 4);
                _tnet = Transformations.TranslateToOrigin(_vertices, _tnet);
                _tnet = Transformations.ReflectOnYAxis(_tnet);
                _tnet = Transformations.ScaleToIntial(_vertices, _tnet, this.ClientRectangle.Height);

                _tnet = Transformations.TranslateToCenter(_tnet, this.ClientRectangle.Width, this.ClientRectangle.Height);

                Transformations.PrintMatrix(_tnet);
                Invalidate();
            }
        } // end of RestoreInitialImage
Esempio n. 3
0
        protected override void OnPaint(PaintEventArgs pea)
        {
            Graphics grfx = pea.Graphics;
            Pen      pen  = new Pen(Color.White, 3);

            if (_gooddata)
            {
                _scrnpts = Transformations.MatrixMultiply(_vertices, _tnet);

                //now draw the lines

                for (int i = 0; i < _numlines; i++)
                {
                    grfx.DrawLine(pen, (int)_scrnpts[_lines[i, 0], 0], (int)_scrnpts[_lines[i, 0], 1],
                                  (int)_scrnpts[_lines[i, 1], 0], (int)_scrnpts[_lines[i, 1], 1]);
                }
            } // end of gooddata block
        }     // end of OnPaint
Esempio n. 4
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            if (_rotating)
            {
                _rotating = false;
                _thread.Abort();
                _thread.Join();
                _thread = null;
            }
            if (e.Button == transleftbtn)
            {
                _tnet = Transformations.Translate(_tnet, -75, 0, 0);
                Refresh();
            }
            if (e.Button == transrightbtn)
            {
                _tnet = Transformations.Translate(_tnet, +75, 0, 0);
                Refresh();
            }
            if (e.Button == transupbtn)
            {
                _tnet = Transformations.Translate(_tnet, 0, -35, 0);
                Refresh();
            }
            if (e.Button == transdownbtn)
            {
                _tnet = Transformations.Translate(_tnet, 0, +35, 0);
                Refresh();
            }
            if (e.Button == scaleupbtn)
            {
                _tnet = Transformations.TranslateToOrigin(_scrnpts, _tnet);
                _tnet = Transformations.ScaleUniform(_scrnpts, _tnet, 1.10);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }
            if (e.Button == scaledownbtn)
            {
                _tnet = Transformations.TranslateToOrigin(_scrnpts, _tnet);
                _tnet = Transformations.ScaleUniform(_scrnpts, _tnet, 0.90);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }
            if (e.Button == rotxby1btn)
            {
                _tnet = Transformations.TranslateToOrigin(_scrnpts, _tnet);
                _tnet = Transformations.RotateOnX(_tnet, .05);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }
            if (e.Button == rotyby1btn)
            {
                _tnet = Transformations.TranslateToOrigin(_scrnpts, _tnet);
                _tnet = Transformations.RotateOnY(_tnet, .05);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }
            if (e.Button == rotzby1btn)
            {
                _tnet = Transformations.TranslateToOrigin(_scrnpts, _tnet);
                _tnet = Transformations.RotateOnZ(_tnet, .05);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }

            if (e.Button == rotxbtn)
            {
                _rotating = true;
                _thread   = new Thread(new ThreadStart(RotateXAsync));
                _thread.Start();
            }
            if (e.Button == rotybtn)
            {
                _rotating = true;
                _thread   = new Thread(new ThreadStart(RotateYAsync));
                _thread.Start();
            }

            if (e.Button == rotzbtn)
            {
                _rotating = true;
                _thread   = new Thread(new ThreadStart(RotateZAsync));
                _thread.Start();
            }

            if (e.Button == shearleftbtn)
            {
                _tnet = Transformations.TranslateBaselineToXaxis(_vertices, _scrnpts, _tnet);
                _tnet = Transformations.ShearHorizontal(_tnet, 0.10);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }

            if (e.Button == shearrightbtn)
            {
                _tnet = Transformations.TranslateBaselineToXaxis(_vertices, _scrnpts, _tnet);
                _tnet = Transformations.ShearHorizontal(_tnet, -0.10);
                _tnet = Transformations.Translate(_tnet, Transformations.PreviousXPos, Transformations.PreviousYPos, Transformations.PreviousZPos);
                Refresh();
            }

            if (e.Button == resetbtn)
            {
                RestoreInitialImage();
            }

            if (e.Button == exitbtn)
            {
                Close();
            }
        }