Пример #1
0
        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));
        }
Пример #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) });
        }
Пример #3
0
        public static GridInterval FromRealLength(int min, double realLength)
        {
            var gridLength = GridConvert.ToGrid(realLength);

            return(FromLength(min, gridLength));
        }
Пример #4
0
 public static GridInterval FromRealInterval(double min, double maxExcl)
 {
     return(FromExclusiveMax(GridConvert.ToGrid(min), GridConvert.ToGrid(maxExcl)));
 }
Пример #5
0
 public static (double x, double y) ToReal(GridCoordinatePair gridCoordinates)
 {
     return(GridConvert.ToReal(gridCoordinates.X), GridConvert.ToReal(gridCoordinates.Y));
 }
Пример #6
0
 /// <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)));
 }
Пример #7
0
 public GridCoordinatePair ToGridCartesian()
 {
     var(x, y) = ToRealCartesian();
     return(new GridCoordinatePair(GridConvert.ToGrid(x), GridConvert.ToGrid(y)));
 }