/// <summary> /// The quantity of days by year. first approach 360 days is a year. /// </summary> //readonly int QuantityDaysByYear = 360; public Planet() { this.GalaxyPosition = new PlanetCoordinates(0.0, 0.0); this.PlanetSpeed = 0; this.Direction = Enumerators.PlanetTranslation.Clockwise; this.radio = 1; }
public async Task PointSkyObject(StellarObjectDesignation stellarObjectDesignation) { var observer = new Observer { Latitude = 45.42546991419586, Longitude = 23.9497447013855, Altitude = 595 }; double epoch = GetJulianDate(DateTime.Now); PlanetCoordinates planetCoordinates = await GetPlanetCoordinates(stellarObjectDesignation, epoch, observer); var rightAscension = new RightAscension(); rightAscension.ConvertFromArcSec(planetCoordinates.RightAscensionInArcSec); var declination = new Declination(); declination.ConvertFromArcSec(planetCoordinates.DeclinationInArcSec); CelestialCoordinates celestialCoordinates = EquatorialCoordinatesConverter.ToCelestialCoordinates( rightAscension.Longitude, declination.Latitude, observer.Latitude, observer.Longitude); double roundedAltitude = Math.Round(celestialCoordinates.Altitude); double roundedAzimuth = Math.Round(celestialCoordinates.Azimuth); double servoMotorValue = roundedAltitude; if (servoMotorValue > 0) { servoMotorValue += 90; } else { servoMotorValue = 90 - Math.Abs(servoMotorValue); } using var serialPort = new SerialPort { PortName = SerialPort.GetPortNames().First(), BaudRate = 9600, Parity = Parity.None, StopBits = StopBits.One, DataBits = 8, Handshake = Handshake.None, RtsEnable = true }; serialPort.Open(); var command = $"<S{roundedAzimuth};A{servoMotorValue};B{servoMotorValue};C{servoMotorValue}>"; serialPort.WriteLine(command); }
}// bool IsSunInsideTriangle() { PlanetCoordinates coord1 = betasoide.GalaxyPosition; PlanetCoordinates coord2 = vulcano.GalaxyPosition; PlanetCoordinates coord3 = ferengi.GalaxyPosition; PlanetCoordinates P = sun.GalaxyPosition; if (TriangleArea(coord1, coord2, coord3) >= 0) { return(TriangleArea(coord1, coord2, P) >= 0 && TriangleArea(coord2, coord3, P) >= 0 && TriangleArea(coord3, coord1, P) >= 0); } else { return(TriangleArea(coord1, coord2, P) <= 0 && TriangleArea(coord2, coord3, P) <= 0 && TriangleArea(coord3, coord1, P) <= 0); } }//
/// <summary> /// in circle the max perimeter for a triangle inside is an isoceles /// </summary> /// <returns><c>true</c>, if max rain was ised, <c>false</c> otherwise.</returns> private bool isMaxRain() { //to calculate the isoceles, select the farest planet from that place mesuare the distance of two segments are the same. PlanetCoordinates A = betasoide.GalaxyPosition; PlanetCoordinates B = vulcano.GalaxyPosition; PlanetCoordinates C = ferengi.GalaxyPosition; double xs1 = Math.Round(B.X - A.X, 2); double ys1 = Math.Round(B.Y - A.Y, 2); double distanceAB = Math.Round(Math.Sqrt(Math.Pow(xs1, 2) + Math.Pow(ys1, 2)), 2); double xs2 = Math.Round(C.X - A.X, 2); double ys2 = Math.Round(C.Y - A.Y, 2); double distanceAC = Math.Round(Math.Sqrt(Math.Pow(xs2, 2) + Math.Pow(ys2, 2)), 2); double xs3 = Math.Round(B.X - C.X, 2); double ys3 = Math.Round(B.Y - C.Y, 2); double distanceBC = Math.Round(Math.Sqrt(Math.Pow(xs3, 2) + Math.Pow(ys3, 2)), 2); double error = ERROR_DECIMAL; error = GetMinimalError(distanceAB, distanceAC); if (Math.Abs(distanceAB - distanceAC) <= error) { return(true); } error = GetMinimalError(distanceAB, distanceBC); if (Math.Abs(distanceAB - distanceBC) <= error) { return(true); } error = GetMinimalError(distanceAC, distanceBC); if (Math.Abs(distanceAC - distanceBC) <= error) { return(true); } return(false); }
public YuanShape(PlanetCoordinates c, List <CoordinateThree> points) { CenterPointCoordinates = c; BoundaryPoints = points; }
public Sun() { this.GalaxyPosition = new PlanetCoordinates(0.0, 0.0); }
double TriangleArea(PlanetCoordinates coord1, PlanetCoordinates coord2, PlanetCoordinates coord3) { //triangle area cord1, cord2, cord3, area > 0 return((coord1.X - coord3.X) * (coord2.Y - coord3.Y) - (coord1.Y - coord3.Y) * (coord2.X - coord3.X)); }//