public void SetData(int cid, int sid)
        {
            chart1.Series.Clear();
            chart1.ChartAreas.Clear();

            // ChartにSeriesを追加します
            string legend1 = "X";
            string legend2 = "Y";
            string legend3 = "Z";
            string legend4 = "cost";

            chart1.Series.Add(legend1);
            chart1.Series.Add(legend2);
            chart1.Series.Add(legend3);
            chart1.Series.Add(legend4);

            chart1.Series[legend1].ChartType = SeriesChartType.Line; // 折れ線グラフ
            chart1.Series[legend2].ChartType = SeriesChartType.Line; // 折れ線グラフ
            chart1.Series[legend3].ChartType = SeriesChartType.Line; // 折れ線グラフ
            chart1.Series[legend4].ChartType = SeriesChartType.Line; // 折れ線グラフ

            chart1.ChartAreas.Add(new ChartArea("Area1"));
            chart1.ChartAreas["Area1"].AxisX.Title = "time";
            chart1.ChartAreas["Area1"].AxisY.Title = "degree";

            //クラスタ型から拾ってくる
            //Centroid のグラフ出力 sid == 0
            if (sid == 0)
            {
                Cluster c = kmeans.clusters[cid];
                for (int i = 0; i < c.centroid.DBAacc.Length; i++)
                {
                    chart1.Series[legend1].Points.AddY(c.centroid.DBAacc[i].x); //X
                    chart1.Series[legend2].Points.AddY(c.centroid.DBAacc[i].y); //Y
                    chart1.Series[legend3].Points.AddY(c.centroid.DBAacc[i].z); //Z
                }
                laShoot.Text    = "Centroid";
                laShootNum.Text = "";
                distNum.Text    = " ";
            }
            //各クラスタに属する射の入力データのグラフ出力 Centroidに距離が近い順(Sort済み)
            else
            {
                //クラスタ番号cidのクラスタ
                Cluster c = kmeans.clusters[cid];
                //クラスタ番号cidのメンバー 
                Shoot    s   = c.members[sid - 1];
                DBAShoot dba = c.centroid;
                laShoot.Text    = "Shoot";
                laShootNum.Text = s.shootnumber.ToString();
                distNum.Text    = DBA.CalcCost(s.acc, dba.DBAacc).dist.ToString();
                //double dt = 0.1;
                //double[] dtCost = new double[s.acc.Length];
                for (int i = 0; i < s.acc.Length - 1; i++)
                {
                    chart1.Series[legend1].Points.AddXY(s.time[i], s.acc[i].x); //X
                    chart1.Series[legend2].Points.AddXY(s.time[i], s.acc[i].y); //Y
                    chart1.Series[legend3].Points.AddXY(s.time[i], s.acc[i].z); //Z
                }

                //costのグラフも表示
                for (int i = 0; i < s.cost.Length; i++)
                {
                    ////chart1.Series[legend4].Points.AddY(s.path[i]); //cost
                    //dtCost[i] = (s.cost[i] - s.cost[i - 1]) / dt;
                    //dtCost[i] = s.cost[i];
                    //costの軸は2軸目(右側のY軸目盛り)で表示
                    double[] DBAcost = DBA.CalcCost(s.acc, dba.DBAacc).cost;

                    chart1.Series[legend4].YAxisType = AxisType.Secondary;
                    //chart1.Series[legend4].Points.AddXY(dba.DBAtime[i], s.cost[i]); //cost
                    chart1.Series[legend4].Points.AddXY(s.time[i], DBAcost[i]); //cost
                }
            }
        }
Exemplo n.º 2
0
        public void SetData(int cid, int sid)
        {
            chart1.Series.Clear();
            chart1.ChartAreas.Clear();

            // ChartにSeriesを追加します
            string legend1 = "X";
            string legend2 = "Y";
            string legend3 = "Z";

            chart1.Series.Add(legend1);
            chart1.Series.Add(legend2);
            chart1.Series.Add(legend3);


            chart1.Series[legend1].ChartType = SeriesChartType.Line; // 折れ線グラフ
            chart1.Series[legend2].ChartType = SeriesChartType.Line; // 折れ線グラフ
            chart1.Series[legend3].ChartType = SeriesChartType.Line; // 折れ線グラフ

            chart1.ChartAreas.Add(new ChartArea("Area1"));
            chart1.ChartAreas["Area1"].AxisX.Title = "time";
            chart1.ChartAreas["Area1"].AxisY.Title = "degree";

            //クラスタ型から拾ってくる
            //Centroid のグラフ出力 sid == 0
            if (sid == 0)
            {
                Cluster c = kmeans.clusters[cid];
                for (int i = 0; i < c.centroid.DBAacc.Length; i++)
                {
                    chart1.Series[legend1].Points.AddY(c.centroid.DBAacc[i].x); //X
                    chart1.Series[legend2].Points.AddY(c.centroid.DBAacc[i].y); //Y
                    chart1.Series[legend3].Points.AddY(c.centroid.DBAacc[i].z); //Z
                }
                laShoot1.Text    = "Centroid";
                laShootNum1.Text = "";
            }
            //各クラスタに属する射の入力データのグラフ出力 Centroidに距離が近い順(Sort済み)
            else
            {
                //  //クラスタ番号cidのクラスタ
                Cluster c = kmeans.clusters[cid];
                //クラスタ番号cidのメンバー 
                Shoot    s   = c.members[sid - 1];
                DBAShoot dba = c.centroid;
                laShoot1.Text    = "Shoot";
                laShootNum1.Text = s.shootnumber.ToString();
                if (video[0] != null)
                {
                    video[0].SetShootNum(s.shootnumber);
                }

                for (int i = 0; i < s.acc.Length - 1; i++)
                {
                    chart1.Series[legend1].Points.AddXY(s.time[i], s.acc[i].x); //X
                    chart1.Series[legend2].Points.AddXY(s.time[i], s.acc[i].y); //Y
                    chart1.Series[legend3].Points.AddXY(s.time[i], s.acc[i].z); //Z
                }

                //Setupのとき
                trackBar1.Minimum = (int)s.time[0] * ViewShootingVideo.fps;
                trackBar1.Maximum = (int)s.time[s.acc.Length - 1] * ViewShootingVideo.fps;
                System.Diagnostics.Debug.WriteLine("video1 t0=" + s.time[0] + " tn=" + s.time[s.acc.Length - 1]);
            }
        }