private static bool IsThetaMultipleOf90Degress(double theta) { double x = Math.Abs(Math.Sin(theta)); double num4 = Math.Abs(Math.Cos(theta)); if (!DoubleUtil.IsCloseToZero(x) && !DoubleUtil.IsCloseToZero(num4)) { return(false); } return(true); }
public DoubleExtension(double value) { if (DoubleUtil.IsCloseToZero(value)) { _boxedValue = BoxedConstants.Double.Zero; } else if (DoubleUtil.IsCloseToOne(value)) { _boxedValue = BoxedConstants.Double.One; } else if (value.IsNaN()) { _boxedValue = BoxedConstants.Double.NaN; } _boxedValue = value; }
public static bool IsCloseToZero(this PointDouble pt) => (DoubleUtil.IsCloseToZero(pt.X) && DoubleUtil.IsCloseToZero(pt.Y));
public static bool IsCloseToZero(this VectorDouble vec) => (DoubleUtil.IsCloseToZero(vec.X) && DoubleUtil.IsCloseToZero(vec.Y));
private bool AutoScrollIfNecessary(PointDouble position) { if (!this.autoScroll || !this.CanPan()) { return(false); } RectDouble viewportCanvasBounds = this.CanvasView.ViewportCanvasBounds; RectDouble canvasBounds = this.CanvasView.GetCanvasBounds(); double x = DoubleUtil.Lerp((viewportCanvasBounds.Left + viewportCanvasBounds.Right) / 2.0, position.X, 1.02); PointDouble num3 = new PointDouble(x, DoubleUtil.Lerp((viewportCanvasBounds.Top + viewportCanvasBounds.Bottom) / 2.0, position.Y, 1.02)); double num15 = (num3.X < viewportCanvasBounds.Left) ? ((double)(-1)) : ((num3.X > viewportCanvasBounds.Right) ? ((double)1) : ((double)0)); double y = (num3.Y < viewportCanvasBounds.Top) ? ((double)(-1)) : ((num3.Y > viewportCanvasBounds.Bottom) ? ((double)1) : ((double)0)); VectorDouble vec = new VectorDouble(num15, y); if (vec.IsCloseToZero()) { return(false); } TimeSpan span = (TimeSpan)(DateTime.UtcNow - this.lastAutoScrollTime); double num5 = DoubleUtil.Clamp(span.TotalSeconds, 0.0, 0.1); if (DoubleUtil.IsCloseToZero(num5)) { return(false); } double num6 = (double)AppSettings.Instance.Workspace.AutoScrollViewportPxPerSecond.Value; VectorDouble viewportVec = (VectorDouble)((num5 * vec) * num6); PointDouble viewportCanvasOffset = this.CanvasView.ViewportCanvasOffset; VectorDouble num9 = this.CanvasView.ConvertViewportToCanvas(viewportVec); double left = UIUtil.ScaleWidth((double)5.0); double top = UIUtil.ScaleHeight((double)5.0); ThicknessDouble num12 = new ThicknessDouble(left, top, left, top); VectorDouble zero = VectorDouble.Zero; if ((num9.X < 0.0) && (viewportCanvasBounds.Left > -num12.Left)) { zero.X = Math.Max(num9.X, -(viewportCanvasBounds.Left + num12.Left)); } if ((num9.Y < 0.0) && (viewportCanvasBounds.Top > -num12.Top)) { zero.Y = Math.Max(num9.Y, -(viewportCanvasBounds.Top + num12.Top)); } if ((num9.X > 0.0) && (viewportCanvasBounds.Right < (canvasBounds.Right + num12.Right))) { zero.X = Math.Min(num9.X, (canvasBounds.Right + num12.Right) - viewportCanvasBounds.Right); } if ((num9.Y > 0.0) && (viewportCanvasBounds.Bottom < (canvasBounds.Bottom + num12.Bottom))) { zero.Y = Math.Min(num9.Y, (canvasBounds.Bottom + num12.Bottom) - viewportCanvasBounds.Bottom); } if (zero.IsCloseToZero()) { return(false); } PointDouble num14 = viewportCanvasOffset + zero; this.ResetLastAutoScrollTime(); this.CanvasView.ViewportCanvasOffset = num14; this.Update(); return(true); }