コード例 #1
0
 // Use this for initialization
 void Start()
 {
     //initialEuler = new Vector3(270, -90, 90);
     initialPos = transform.position;
     using (var textReader = File.OpenText("BouncingBall_res.csv"))
     {
         using (var csv = new CsvReader(textReader))
         {
             float?firstTime = null;
             while (csv.Read())
             {
                 //Debug.LogFormat("Reading: {0}", (object)csv.CurrentRecord);
                 var record = new BouncingRes {
                     time    = float.Parse(csv.CurrentRecord[0]),
                     Vx      = float.Parse(csv.CurrentRecord[1]),
                     Vy      = float.Parse(csv.CurrentRecord[2]),
                     x       = float.Parse(csv.CurrentRecord[3]),
                     y       = float.Parse(csv.CurrentRecord[4]),
                     der_Vx  = float.Parse(csv.CurrentRecord[5]),
                     der_Vy  = float.Parse(csv.CurrentRecord[6]),
                     der_x   = float.Parse(csv.CurrentRecord[7]),
                     der_y   = float.Parse(csv.CurrentRecord[8]),
                     ax      = float.Parse(csv.CurrentRecord[9]),
                     g       = float.Parse(csv.CurrentRecord[10]),
                     stair1x = float.Parse(csv.CurrentRecord[11]),
                     stair1y = float.Parse(csv.CurrentRecord[12]),
                 };
                 //if (!records.ContainsKey(record.time))
                 //{
                 //    records.Add(record.time, record);
                 //}
                 records.Add(record);
                 if (firstTime == null)
                 {
                     firstTime = record.time;
                 }
                 else if (timeStep == null)
                 {
                     timeStep = record.time - firstTime;
                 }
                 maxTime = record.time;
             }
         }
     }
     maxTimeInt = records.Count - 1;
     Debug.LogFormat("Records {0}: {1}", records.Count, records);
 }
コード例 #2
0
ファイル: simulate.cs プロジェクト: tmdgitb/bouncingsim
 // Use this for initialization
 void Start()
 {
     //initialEuler = new Vector3(270, -90, 90);
     initialPos = transform.position;
     using (var textReader = File.OpenText("BouncingBall_res.csv"))
     {
         using (var csv = new CsvReader(textReader))
         {
             float? firstTime = null;
             while (csv.Read())
             {
                 //Debug.LogFormat("Reading: {0}", (object)csv.CurrentRecord);
                 var record = new BouncingRes {
                     time = float.Parse(csv.CurrentRecord[0]),
                     Vx = float.Parse(csv.CurrentRecord[1]),
                     Vy = float.Parse(csv.CurrentRecord[2]),
                     x = float.Parse(csv.CurrentRecord[3]),
                     y = float.Parse(csv.CurrentRecord[4]),
                     der_Vx = float.Parse(csv.CurrentRecord[5]),
                     der_Vy = float.Parse(csv.CurrentRecord[6]),
                     der_x = float.Parse(csv.CurrentRecord[7]),
                     der_y = float.Parse(csv.CurrentRecord[8]),
                     ax = float.Parse(csv.CurrentRecord[9]),
                     g = float.Parse(csv.CurrentRecord[10]),
                     stair1x = float.Parse(csv.CurrentRecord[11]),
                     stair1y = float.Parse(csv.CurrentRecord[12]),
                 };
                 //if (!records.ContainsKey(record.time))
                 //{
                 //    records.Add(record.time, record);
                 //}
                 records.Add(record);
                 if (firstTime == null)
                 {
                     firstTime = record.time;
                 } else if (timeStep == null)
                 {
                     timeStep = record.time - firstTime;
                 }
                 maxTime = record.time;
             }
         }
     }
     maxTimeInt = records.Count - 1;
     Debug.LogFormat("Records {0}: {1}", records.Count, records);
 }