Beispiel #1
0
        public bool CheckBalancedPointOnSpiral(Point point)
        {
            var spiral        = new ArchimedeanSpiral(Center, angleStep, SpiralRadius);
            var balancedPoint = spiral.BalancePoint(spiral.GetPoint());

            while (point.GetDistance(Center) - balancedPoint.GetDistance(Center) > RadiusDifference)
            {
                balancedPoint = spiral.BalancePoint(spiral.GetPoint());
                if (balancedPoint == point)
                {
                    return(true);
                }
            }

            return(false);
        }
        private Point ChoosePoint()
        {
            Point point;

            do
            {
                var pointOnSpiral = Spiral.GetPoint();
                point = Spiral.BalancePoint(pointOnSpiral);
            }while (Rectangles.ContainPoint(point));
            return(point);
        }
Beispiel #3
0
        public void CheckSpiralPoints_MustBeCorrectlyDefined(int numberOfPoints)
        {
            for (var i = 0; i < numberOfPoints; i++)
            {
                var spiralPoint = spiral.GetPoint();

                spiralPoint = Tuple.Create(spiralPoint.Item1 - spiral.Center.X, spiralPoint.Item2 - spiral.Center.Y);

                var sumXYSquares         = Math.Pow(spiralPoint.Item1, 2) + Math.Pow(spiralPoint.Item2, 2);
                var radiusAndAngleSquare = Math.Pow(spiral.SpiralAngle * spiral.SpiralRadius, 2);

                Assert.True(Math.Abs(sumXYSquares - radiusAndAngleSquare) < 0.000001);
            }
        }