コード例 #1
0
        /// <summary>Getting distance from the surface directly under the lander, but we don't need to find the surface
        /// elements under the lander.</summary>
        public static int GetDistanceFromSurface(Lander lander, SurfaceZone leftZone, SurfaceZone rightZone)
        {
            if (rightZone == null || leftZone == null)
            {
                return(int.MaxValue);
            }
            var zoneAngle = Trigonometry
                            .GetAngle(new Point(leftZone.LeftX, leftZone.LeftY), new Point(rightZone.LeftX, rightZone.LeftY));
            var landerXInZone    = lander.Situation.X - leftZone.LeftX;
            var surfaceYPosition = leftZone.LeftY +
                                   Math.Round(Trigonometry.GetNewYPosition(zoneAngle, landerXInZone));

            return((int)Math.Round(lander.Situation.Y - surfaceYPosition));
        }
コード例 #2
0
 public SurfaceZone(int leftX, int leftY, int rightX, int rightY)
 {
     LeftX           = leftX;
     LeftY           = leftY;
     RightX          = rightX;
     RightY          = rightY;
     Angle           = Trigonometry.GetAngle(new Point(LeftX, LeftY), new Point(RightX, RightY));
     SurfaceElements = new List <SurfaceElement>();
     for (var x = leftX; x < rightX; x++)
     {
         SurfaceElements.Add(new SurfaceElement {
             X = x, Y = LeftY + Trigonometry.GetNewYPosition(Angle, x - leftX)
         });
     }
 }
コード例 #3
0
 public void GetYPosition_ValidParameters_ReturnsValidYPosition(double angle, double xLength, double yResult, int decimals = 3)
 {
     Assert.That(Trigonometry.GetNewYPosition(angle, xLength, decimals), Is.EqualTo(yResult));
 }