private (double x, double y) ToRealCartesian()
        {
            // grid polar coordinates convert to floating point values over grid space
            var x = Radius * Math.Cos(Theta);
            var y = Radius * Math.Sin(Theta);

            // those values are now translated to real space, which has origin in (0.5,0.5)
            return(GridConvert.ToReal(x), GridConvert.ToReal(y));
        }
Esempio n. 2
0
        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) });
        }
Esempio n. 3
0
        public static GridInterval FromRealLength(int min, double realLength)
        {
            var gridLength = GridConvert.ToGrid(realLength);

            return(FromLength(min, gridLength));
        }
Esempio n. 4
0
 public static GridInterval FromRealInterval(double min, double maxExcl)
 {
     return(FromExclusiveMax(GridConvert.ToGrid(min), GridConvert.ToGrid(maxExcl)));
 }
 public static (double x, double y) ToReal(GridCoordinatePair gridCoordinates)
 {
     return(GridConvert.ToReal(gridCoordinates.X), GridConvert.ToReal(gridCoordinates.Y));
 }
 /// <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)));
 }