Example #1
0
 public float DistanceTo(Point2 P)
 {
     return (float)Math.Sqrt(Math.Pow(P.X - X, 2) + Math.Pow(P.Y - Y, 2));
 }
Example #2
0
 public float DistanceTo(Point2 P)
 {
     return((float)Math.Sqrt(Math.Pow(P.X - X, 2) + Math.Pow(P.Y - Y, 2)));
 }
Example #3
0
 public Point2(Point2 p)
 {
     this.X = p.X;
     this.Y = p.Y;
 }
Example #4
0
 public Point2 Lerp(Point2 other, float t)
 {
     return((1 - t) * this + t * other);
 }
 private void HandleReplayChanged(Replay r, Beatmap b)
 {
     Chart.SuspendLayout();
     Chart.Series.Clear();
     Chart.ChartAreas[0].AxisX.ScaleView.ZoomReset(0);
     Chart.ChartAreas[0].AxisY.ScaleView.ZoomReset(0);
     int currentSpinnerNumber = 1;
     foreach (var spinner in b.HitObjects.Where(o => o.GetType() == typeof(SpinnerObject)))
     {
         Point2 currentPosition = new Point2(-500, -500);
         Dictionary<double, int> RPMCount = new Dictionary<double, int>();
         double currentTime = 0;
         foreach (ReplayInfo repPoint in r.ReplayFrames.Where(repPoint => repPoint.Time < ((SpinnerObject)spinner).EndTime && repPoint.Time > spinner.StartTime))
         {
             if ((int)currentPosition.X == -500)
             {
                 currentPosition.X = repPoint.X;
                 currentPosition.Y = repPoint.Y;
             }
             else
             {
                 currentTime += repPoint.TimeDiff;
                 if (RPMCount.Keys.Contains(currentTime))
                     continue;
                 double ptsDist = currentPosition.DistanceTo(new Point2(repPoint.X, repPoint.Y));
                 double p1CDist = currentPosition.DistanceTo(spinner.Location);
                 double p2CDist = new Point2(repPoint.X, repPoint.Y).DistanceTo(spinner.Location);
                 double travelDegrees = Math.Acos((Math.Pow(p1CDist, 2) + Math.Pow(p2CDist, 2) - Math.Pow(ptsDist, 2)) / (2 * p1CDist * p2CDist)) * (180 / Math.PI);
                 RPMCount.Add(currentTime, (int)Math.Min((travelDegrees / (0.006 * repPoint.TimeDiff)), 477));
                 currentPosition.X = repPoint.X;
                 currentPosition.Y = repPoint.Y;
             }
         }
         int count = 0;
         int valueAmnt = 0;
         Series spinnerSeries = new Series
         {
             ChartType = SeriesChartType.Spline,
             BorderWidth = 2,
             Name = oRA.Data.Language["oRA_Spinner"] + " " + currentSpinnerNumber
         };
         foreach (var frame in RPMCount)
         {
             valueAmnt += frame.Value;
             count += 1;
             if (count == 5)
             {
                 spinnerSeries.Points.AddXY(frame.Key, Convert.ToInt32(valueAmnt / count));
                 count = 0;
                 valueAmnt = 0;
             }
         }
         Chart.Series.Add(spinnerSeries);
         currentSpinnerNumber += 1;
     }
     Chart.ResumeLayout();
 }