예제 #1
0
        public COORDS generateRandomLocation(int minRadius, int maxRadius)
        {
            COORDS randomSpot = new COORDS();

            randomRadius = rand.Next(minRadius, maxRadius);
            roverScience.setScienceMaxRadiusBoost(randomRadius);


            double bodyRadius       = vessel.mainBody.Radius;
            double randomAngle      = rand.NextDouble() * (double)(1.9);
            double randomTheta      = (randomAngle * (Math.PI));
            double angularDistance  = randomRadius / bodyRadius;
            double currentLatitude  = vessel.latitude.ToRadians();
            double currentLongitude = vessel.longitude.ToRadians();

            double spotLat = Math.Asin(Math.Sin(currentLatitude) * Math.Cos(angularDistance) +
                                       Math.Cos(currentLatitude) * Math.Sin(angularDistance) * Math.Cos(randomTheta));

            double spotLon = currentLongitude + Math.Atan2(Math.Sin(randomTheta) * Math.Sin(angularDistance) * Math.Cos(currentLatitude),
                                                           Math.Cos(angularDistance) - Math.Sin(currentLatitude) * Math.Sin(spotLat));

            randomSpot.latitude  = spotLat.ToDegrees();
            randomSpot.longitude = spotLon.ToDegrees();

            return(randomSpot);
        }
예제 #2
0
        public double getDistanceBetweenTwoPoints(COORDS _from, COORDS _to)
        {
            double bodyRadius = vessel.mainBody.Radius;
            double dLat       = (_to.latitude - _from.latitude).ToRadians();
            double dLon       = (_to.longitude - _from.longitude).ToRadians();
            double lat1       = _from.latitude.ToRadians();
            double lat2       = _to.latitude.ToRadians();

            double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                       Math.Sin(dLon / 2) * Math.Sin(dLon / 2) * Math.Cos(lat1) * Math.Cos(lat2);
            double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
            double d = bodyRadius * c;

            return(Math.Round(d, 4));
        }
예제 #3
0
        public double getBearingFromCoords(COORDS target)
        {
            // Rover x,y position

            double dLat = (target.latitude - location.latitude).ToRadians();
            double dLon = (target.longitude - location.longitude).ToRadians();
            double lat1 = location.latitude.ToRadians();
            double lat2 = target.latitude.ToRadians();

            double y = Math.Sin(dLon) * Math.Cos(lat2);
            double x = Math.Cos(lat1) * Math.Sin(lat2) -
                       Math.Sin(lat1) * Math.Cos(lat2) * Math.Cos(dLon);

            double bearing = Math.Atan2(y, x).ToDegrees();

            //bearing = (bearing + 180) % 360;

            //return bearing % 360;
            return((bearing + 360) % 360);
        }
예제 #4
0
        // Method to set location
        public void setLocation(double longitude = 0, double latitude = 0, bool random = false, bool anomaly = false)
        {
            // generate random radius for where to spot placement
            // bool random will override whatever is entered

            if (!random)
            {
                location.latitude  = latitude;
                location.longitude = longitude;
            }
            else
            {
                COORDS randomSpot = generateRandomLocation(rover.minRadius, rover.maxRadius);
                location.latitude  = randomSpot.latitude;
                location.longitude = randomSpot.longitude;
            }

            established = true;

            this.generateScience(anomaly);
            predictSpot(anomaly);

            rover.distanceTraveledTotal = 0;

            //Debug.Log("== setLocation() ==");
            //Debug.Log("randomAngle: " + Math.Round(randomAngle, 4));
            //Debug.Log("randomTheta (radians): " + Math.Round(randomTheta, 4));
            //Debug.Log("randomTheta (degrees?): " + Math.Round((randomTheta.ToDegrees()), 4));
            //Debug.Log(" ");
            //Debug.Log("randomRadius selected: " + randomRadius);
            //Debug.Log("distance to ScienceSpot: " + rover.distanceFromScienceSpot);

            //Debug.Log("lat/long: " + location.latitude + " " + location.longitude);
            //Debug.Log("==================");

            DrawWaypoint.Instance.setMarkerLocation(location.longitude, location.latitude, spawningObject: !anomaly);
            DrawWaypoint.Instance.showMarker();
        }