Пример #1
0
        public AttiPlot(Form1 owner)
        {
            a_page = owner.pages.a;
            ahrs   = owner.AHRS;

            InitializeComponent();
            gyroPane = zedGraphControl1.GraphPane;
            gyroPane.Title.IsVisible  = false;
            gyroPane.XAxis.Title.Text = "time (sec)";
            gyroPane.YAxis.Title.Text = "attitude (deg)";

            // Save 1200 points.  At 50 ms sample rate, this is one minute
            // The RollingPointPairList is an efficient storage class that always
            // keeps a rolling set of point data without needing to shift any data values
            RollingPointPairList gxlist = new RollingPointPairList(2000);
            RollingPointPairList gylist = new RollingPointPairList(2000);
            RollingPointPairList gzlist = new RollingPointPairList(2000);

            // Initially, a curve is added with no data points (list is empty)
            // Color is blue, and there will be no symbols
            LineItem curve = gyroPane.AddCurve("Pitch", gxlist, Color.Blue, SymbolType.None);

            curve = gyroPane.AddCurve("Roll", gylist, Color.Red, SymbolType.None);
            curve = gyroPane.AddCurve("Yaw", gzlist, Color.Green, SymbolType.None);

            // Sample at 50ms intervals
            timer1.Interval = 10;
            timer1.Enabled  = true;
            timer1.Start();

            // Just manually control the X axis range so it scrolls continuously
            // instead of discrete step-sized jumps
            gyroPane.XAxis.Scale.Min       = 0;
            gyroPane.XAxis.Scale.Max       = (double)numericUpDown1.Value;
            gyroPane.XAxis.Scale.MinorStep = 0.5;
            gyroPane.XAxis.Scale.MajorStep = 1;
            gyroPane.YAxis.Scale.Max       = 180;
            gyroPane.YAxis.Scale.Min       = -180;

            // Scale the axes
            zedGraphControl1.AxisChange();

            // Save the beginning time for reference
            tickStart = Environment.TickCount;
        }
Пример #2
0
        public Cube3D(Form1 owner)
            : base(600, 400, GraphicsMode.Default, "1-2:Camera")
        {
            ahrs = owner.AHRS;

            VSync = VSyncMode.On;

            Keyboard.KeyUp += (sender, e) =>
            {
                //Escapeキーで終了
                if (e.Key == Key.Escape)
                {
                    this.Exit();
                }
            };

            RenderFrame += (sender, e) =>
            {
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                GL.MatrixMode(MatrixMode.Modelview);
                Vector3 eyepoint  = new Vector3(0, 0, -3);
                Matrix4 modelview = Matrix4.LookAt(eyepoint, Vector3.UnitZ, Vector3.UnitY);
                GL.LoadMatrix(ref modelview);

                Quaternion q = new Quaternion(ahrs.Quaternion[1],
                                              ahrs.Quaternion[2],
                                              ahrs.Quaternion[3],
                                              ahrs.Quaternion[0]);
                float          angle;
                OpenTK.Vector3 vec3 = new Vector3();
                q.ToAxisAngle(out vec3, out angle);
                GL.Rotate((float)(angle * 180 / Math.PI), vec3);

                //float deg = 0;
                //GL.Rotate(deg, Vector3d.UnitY);
                //deg += 1;

                DrawCube();

                SwapBuffers();
            };
        }