public static GridInterval[] Separate(GridInterval i1, GridInterval i2) { var depth = i1.Depth(i2); if (depth == 0) { return new[] { i1, i2 } } ; var t1 = GridConvert.ToGrid(depth / 2.0); var t2 = depth % 2 == 0 ? -t1 : GridConvert.ToGrid(-(depth + 1) / 2.0); return(new[] { i1.Translation(t1), i2.Translation(t2) }); }
public static GridInterval FromRealLength(int min, double realLength) { var gridLength = GridConvert.ToGrid(realLength); return(FromLength(min, gridLength)); }
public static GridInterval FromRealInterval(double min, double maxExcl) { return(FromExclusiveMax(GridConvert.ToGrid(min), GridConvert.ToGrid(maxExcl))); }
/// <summary> /// Correctly maps coordinates from continuous coordinate system to grid coordinate system by flooring the values. /// </summary> /// <param name="x">x ordinate in real space</param> /// <param name="y">y ordinate in real space</param> /// <returns>Corresponding GridCoordinate</returns> public static GridCoordinatePair FromReal(double x, double y) { return(new GridCoordinatePair(GridConvert.ToGrid(x), GridConvert.ToGrid(y))); }
public GridCoordinatePair ToGridCartesian() { var(x, y) = ToRealCartesian(); return(new GridCoordinatePair(GridConvert.ToGrid(x), GridConvert.ToGrid(y))); }