public object Clone() { return(new LiveSplitState() { Run = Run.Clone() as IRun, Form = Form, Layout = Layout.Clone() as ILayout, Settings = Settings.Clone() as ISettings, LayoutSettings = LayoutSettings.Clone() as LayoutSettings, AdjustedStartTime = AdjustedStartTime, StartTimeWithOffset = StartTimeWithOffset, StartTime = StartTime, TimePausedAt = TimePausedAt, GameTimePauseTime = GameTimePauseTime, isGameTimePaused = isGameTimePaused, LoadingTimes = LoadingTimes, CurrentPhase = CurrentPhase, CurrentSplitIndex = CurrentSplitIndex, CurrentComparison = CurrentComparison, CurrentHotkeyProfile = CurrentHotkeyProfile, CurrentTimingMethod = CurrentTimingMethod, AttemptStarted = AttemptStarted, AttemptEnded = AttemptEnded }); }
public object Clone() { return(new LiveSplitState() { Run = Run.Clone() as IRun, Form = Form, Layout = Layout.Clone() as ILayout, Settings = Settings.Clone() as ISettings, LayoutSettings = LayoutSettings.Clone() as LayoutSettings, StartTime = StartTime, PauseTime = PauseTime, GameTimePauseTime = GameTimePauseTime, isGameTimePaused = isGameTimePaused, LoadingTimes = LoadingTimes, CurrentPhase = CurrentPhase, CurrentSplitIndex = CurrentSplitIndex, CurrentComparison = CurrentComparison, CurrentTimingMethod = CurrentTimingMethod, }); }
public static double[,] ComputeLayoutElevation(IEnumerable<Vector2D> layout, LayoutSettings layoutSettings, int matrixRows, int matrixCols, double sigma, double r, bool normalize, bool cut, double cutStdevMult) { Utils.ThrowException(layout == null ? new ArgumentNullException("layout") : null); Utils.ThrowException(layoutSettings == null ? new ArgumentNullException("layoutSettings") : null); Utils.ThrowException(matrixRows < 1 ? new ArgumentOutOfRangeException("matrixRows") : null); Utils.ThrowException(matrixCols < 1 ? new ArgumentOutOfRangeException("matrixCols") : null); Utils.ThrowException(sigma <= 0 ? new ArgumentOutOfRangeException("sigma") : null); LayoutSettings nrmLayoutSettings = layoutSettings.Clone(); double fX = 1.0 / (layoutSettings.Width - 2.0 * layoutSettings.MarginHoriz); double fY = 1.0 / (layoutSettings.Height - 2.0 * layoutSettings.MarginVert); nrmLayoutSettings.Width *= fX; nrmLayoutSettings.MarginHoriz *= fX; nrmLayoutSettings.Height *= fY; nrmLayoutSettings.MarginVert *= fY; Vector2D[] nrmLayout = nrmLayoutSettings.AdjustLayout(layout); LayoutIndex layoutIndex = new LayoutIndex(); layoutIndex.MaxPointsPerLeaf = 100; // *** hardcoded max points per leaf if (r > 0) { layoutIndex.BuildIndex(nrmLayout); } double[,] zMtx = new double[matrixRows, matrixCols]; Vector2D pixSz = new Vector2D(nrmLayoutSettings.Width / (double)matrixCols, nrmLayoutSettings.Height / (double)matrixRows); double maxZ = 0; double avgZ = 0; int row = 0; for (double y = pixSz.Y / 2.0; y < nrmLayoutSettings.Height; y += pixSz.Y, row++) { int col = 0; for (double x = pixSz.X / 2.0; x < nrmLayoutSettings.Width; x += pixSz.X, col++) { Vector2D pt0 = new Vector2D(x, y); double z = 0; if (r <= 0) { foreach (Vector2D pt in nrmLayout) { double dist = (pt - pt0).GetLength(); z += Math.Exp(-sigma * dist * dist); } } else { foreach (IdxDat<Vector2D> pt in layoutIndex.GetPoints(pt0, r)) { double dist = (pt.Dat - pt0).GetLength(); z += Math.Exp(-sigma * dist * dist); } } zMtx[row, col] = z; if (z > maxZ) { maxZ = z; } avgZ += z; } } avgZ /= (double)(matrixRows * matrixCols); if (avgZ > 0) { if (cut) { double stdev = 0; for (row = 0; row < zMtx.GetLength(0); row++) { for (int col = 0; col < zMtx.GetLength(1); col++) { stdev += (zMtx[row, col] - avgZ) * (zMtx[row, col] - avgZ); } } stdev = Math.Sqrt(stdev / (double)(matrixRows * matrixCols)); maxZ = avgZ + stdev * cutStdevMult; for (row = 0; row < zMtx.GetLength(0); row++) { for (int col = 0; col < zMtx.GetLength(1); col++) { if (zMtx[row, col] > maxZ) { zMtx[row, col] = maxZ; } } } } if (normalize && maxZ > 0) { for (row = 0; row < zMtx.GetLength(0); row++) { for (int col = 0; col < zMtx.GetLength(1); col++) { zMtx[row, col] /= maxZ; } } } } return zMtx; }