public bool ArePlanetsAligned()
        {
            var diffList = GetDifferences();

            var angle = diffList[0].GetAngle();

            return(diffList.All(d => MathUsefulFuntions.AreAnglesAligned(angle, d.GetAngle())));
        }
Beispiel #2
0
        public Planet(int radio, int direction, int velocity)
        {
            this.position = new Position();
            this.movement = new Movement();

            //The radius is measured in kilometers
            this.position.polarPosition.Length = radio;
            //Sense
            this.movement.direction = direction;
            //Velocity
            this.movement.velocity = velocity;
            //Movement of a planet in degrees per day
            this.dayRotation = MathUsefulFuntions.ToRadians(velocity);
        }
        public Weather CalculateWeather()
        {
            if (ArePlanetsAligned())
            {
                //Check if they pass through the center.
                if (MathUsefulFuntions.LineFromTwoPointPassesOrigin(
                        planetList[0].position.polarPosition.ToCartesian(),
                        planetList[1].position.polarPosition.ToCartesian()))
                {
                    return(Weather.CreateDrought());
                }
                else
                {
                    return(Weather.CreateOptimum());
                }
            }

            if (MathUsefulFuntions.IsPointInsideTriangle(new CartesianCoordinates(0, 0), planetList.Select(p => p.position.polarPosition.ToCartesian()).ToList()))
            {
                return(Weather.CreateRainy(this.GetRainIntensity()));
            }

            return(Weather.CreateNormal());
        }
 public PolarCoordinates(double length, double angle)
 {
     this.Length = length;
     this.Angle  = MathUsefulFuntions.NormalizeAngle(angle);
 }
        }                                //Measured in degrees

        public PolarCoordinates()
        {
            this.Length = 0;
            this.Angle  = MathUsefulFuntions.NormalizeAngle(0);
        }