コード例 #1
0
ファイル: DataViewer.cs プロジェクト: kalvdans/openmovement
 public void Add(Sample[] samples)
 {
     foreach (Sample sample in samples)
     {
         Add(sample);
     }
 }
コード例 #2
0
ファイル: DataViewer.cs プロジェクト: kalvdans/openmovement
        public void Add(Sample sample)
        {
            if (!present)
            {
                Min = sample;
                Max = sample;
                present = true;
                return;
            }

            if (sample.T != DateTime.MinValue && sample.T < Min.T) { Min.T = sample.T; } if (sample.T > Max.T) { Max.T = sample.T; }
            if (sample.X < Min.X) { Min.X = sample.X; } if (sample.X > Max.X) { Max.X = sample.X; }
            if (sample.Y < Min.Y) { Min.Y = sample.Y; } if (sample.Y > Max.Y) { Max.Y = sample.Y; }
            if (sample.Z < Min.Z) { Min.Z = sample.Z; } if (sample.Z > Max.Z) { Max.Z = sample.Z; }
            if (sample.Light < Min.Light) { Min.Light = sample.Light; } if (sample.Light > Max.Light) { Max.Light = sample.Light; }
            if (sample.Temp < Min.Temp) { Min.Temp = sample.Temp; } if (sample.Temp > Max.Temp) { Max.Temp = sample.Temp; }
            if (sample.BattPercent < Min.BattPercent) { Min.BattPercent = sample.BattPercent; } if (sample.BattPercent > Max.BattPercent) { Max.BattPercent = sample.BattPercent; }
            if (sample.BattRaw < Min.BattRaw) { Min.BattRaw = sample.BattRaw; } if (sample.BattRaw > Max.BattRaw) { Max.BattRaw = sample.BattRaw; }
            //Min = Sample.Minimum(Min, sample);
            //Max = Sample.Maximum(Max, sample);
        }
コード例 #3
0
ファイル: DataViewer.cs プロジェクト: kalvdans/openmovement
 public DataBlock(DateTime firstTime, DateTime lastTime, float light, float temp, float battpercent, float battraw, short[] raw)
 {
     RawValues = raw;
     Values = new Sample[raw.Length / 3];
     double spanMilliseconds = (lastTime - firstTime).TotalMilliseconds;
     for (int i = 0; i < Values.Length; i++)
     {
         DateTime t;
         if (Values.Length <= 1) { t = firstTime; }
         else { t = firstTime.AddMilliseconds(spanMilliseconds * i / (Values.Length - 1)); }
         float x = raw[3 * i + 0] / 256.0f;
         float y = raw[3 * i + 1] / 256.0f;
         float z = raw[3 * i + 2] / 256.0f;
         Values[i] = new Sample(t, x, y, z, light, temp, battpercent, battraw);
     }
     aggregate.Add(Values);
 }
コード例 #4
0
ファイル: DataViewer.cs プロジェクト: kalvdans/openmovement
 /*
 public static Sample Minimum(Sample a, Sample b)
 {
     if (a.X <= b.X && a.Y <= b.Y && a.Z <= b.Z) { return a; }
     if (b.X <= a.X && b.Y <= a.Y && b.Z <= a.Z) { return b; }
     return new Sample(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z));
 }
 public static Sample Maximum(Sample a, Sample b)
 {
     if (a.X >= b.X && a.Y >= b.Y && a.Z >= b.Z) { return a; }
     if (b.X >= a.X && b.Y >= a.Y && b.Z >= a.Z) { return b; }
     return new Sample(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z));
 }
 */
 public static Sample Interpolate(Sample a, Sample b, float p)
 {
     DateTime t = new DateTime((long)((1.0f - p) * (double)a.T.Ticks + p * (double)b.T.Ticks));
     float x = (1.0f - p) * a.X + p * b.X;
     float y = (1.0f - p) * a.Y + p * b.Y;
     float z = (1.0f - p) * a.Z + p * b.Z;
     float light = (1.0f - p) * a.Light + p * b.Light;
     float temp = (1.0f - p) * a.Temp + p * b.Temp;
     float battpercent = (1.0f - p) * a.BattPercent + p * b.BattPercent;
     float battraw = (1.0f - p) * a.BattRaw + p * b.BattRaw;
     return new Sample(t, x, y, z, light, temp, battpercent, battraw);
 }