public string ToStringDMS(bool newline = false) { double clampedLongitude = AngleUtils.ClampDegrees180(this.Longitude); return(AngleUtils.AngleToDMS(this.Latitude) + (this.Latitude > 0 ? " N" : " S") + (newline ? "\n" : ", ") + AngleUtils.AngleToDMS(clampedLongitude) + (clampedLongitude > 0 ? " E" : " W")); }
public string ToStringDecimal(bool newline = false, int precision = 3) { double clampedLongitude = AngleUtils.ClampDegrees180(this.Longitude); double latitudeAbs = Math.Abs(this.Latitude); double longitudeAbs = Math.Abs(clampedLongitude); return(latitudeAbs.ToString("F" + precision) + "° " + (this.Latitude > 0 ? "N" : "S") + (newline ? "\n" : ", ") + longitudeAbs.ToString("F" + precision) + "° " + (clampedLongitude > 0 ? "E" : "W")); }
public static Coordinates?GetMouseCoordinates(this CelestialBody body) { Ray mouseRay = PlanetariumCamera.Camera.ScreenPointToRay(Input.mousePosition); mouseRay.origin = ScaledSpace.ScaledToLocalSpace(mouseRay.origin); Vector3d relOrigin = mouseRay.origin - body.position; double curRadius = body.pqsController.radiusMax; double lastRadius = 0; int loops = 0; while (loops < 50) { Vector3d relSurfacePosition; if (PQS.LineSphereIntersection(relOrigin, mouseRay.direction, curRadius, out relSurfacePosition)) { Vector3d surfacePoint = body.position + relSurfacePosition; double alt = body.pqsController.GetSurfaceHeight(QuaternionD.AngleAxis(body.GetLongitude(surfacePoint), Vector3d.down) * QuaternionD.AngleAxis(body.GetLatitude(surfacePoint), Vector3d.forward) * Vector3d.right); double error = Math.Abs(curRadius - alt); if (error < (body.pqsController.radiusMax - body.pqsController.radiusMin) / 100) { return(new Coordinates(body.GetLatitude(surfacePoint), AngleUtils.ClampDegrees180(body.GetLongitude(surfacePoint)))); } else { lastRadius = curRadius; curRadius = alt; loops++; } } else { if (loops == 0) { break; } else { // Went too low, needs to try higher curRadius = (lastRadius * 9 + curRadius) / 10; loops++; } } } return(null); }