public class PositionCalculator {
static final double LATITUDE = 47;
static final double LONGITUDE = 15;
static final LocalDateTime OBJECT_DATE_TIME = LocalDateTime.of(2020, Month.APRIL, 11, 22, 00, 00);
public static void main(String[] args) {
new PositionCalculator("Beteigeuze", "5h56m17.41s", "7°24'33.3''");
new PositionCalculator("Sirius", "6h46m03.40s", "-16°44'45.7''");
new PositionCalculator("Regulus", "10h09m28.14s", "11°51'57.0''");
new PositionCalculator("Aldebaran", "4h37m06.45s", "16°32'56.8''");
new PositionCalculator("Capella", "5h18m13.17s", "46°01'00.0''");
new PositionCalculator("Vega", "18h37m38.10s", "38°48'15.3''");
new PositionCalculator("Spica", "13h26m17.00s", "-11°16'06.5''");
new PositionCalculator("Alphard", "9h28m36.10s", "-8°44'56.3''");
new PositionCalculator("West 1", "4h51m44.33s", "8°56'02.3''");
new PositionCalculator("West 2", "4h50m57.74s", "6°59'44.5''");
new PositionCalculator("Denebola", "11h50m06.68s", "14°27'23.7''");
new PositionCalculator("Test 1", "10h33m53.80s", "9°11'59.2''");
}
public PositionCalculator(String name, String object_Rekt, String object_Dekl) {
double raHour = Double.valueOf(object_Rekt.split("h")[0]);
double raMinute = Double.valueOf(object_Rekt.split("h")[1].split("m")[0]);
double raSecond = Double.valueOf(object_Rekt.split("h")[1].split("m")[1].split("s")[0]);
raMinute += raSecond / 60;
double rightAscensionInDegrees = raHour * 15 + raMinute / 4;
double dekDegree = Double.valueOf(object_Dekl.split("°")[0]);
double dekMinute = Double.valueOf(object_Dekl.split("°")[1].split("'")[0]);
double dekSecond = Double.valueOf(object_Dekl.split("°")[1].split("'")[1].split("''")[0]);
dekMinute += dekSecond / 60;
if (dekDegree < 0) {
dekDegree = (dekDegree * -1 + dekMinute / 60) * -1;
} else {
dekDegree = dekDegree + dekMinute / 60;
}
ZonedDateTime localDateTimeAtZone = OBJECT_DATE_TIME.atZone(ZoneId.of("Europe/Berlin"));
ZonedDateTime localDateTimeAtInUTC = ZonedDateTime.ofInstant(localDateTimeAtZone.toInstant(), ZoneOffset.UTC);
SiderealTimeCalculator siderealTimeCalculator = new SiderealTimeCalculator(localDateTimeAtInUTC);
double hourAngle = siderealTimeCalculator.getSiderealTimeAsDegree() - rightAscensionInDegrees;
double sinOfa = Math.sin(Math.toRadians(LATITUDE)) * Math.sin(Math.toRadians(dekDegree))
+ Math.cos(Math.toRadians(LATITUDE)) * Math.cos(Math.toRadians(dekDegree))
* Math.cos(Math.toRadians(hourAngle));
double altitude = Math.toDegrees(Math.asin(sinOfa));
double tanAzimuth = Math.sin(Math.toRadians(hourAngle))
/ ((Math.cos(Math.toRadians(hourAngle)) * Math.sin(Math.toRadians(LATITUDE)))
- (Math.tan(Math.toRadians(dekDegree)) * Math.cos(Math.toRadians(LATITUDE))));
double azimuth = Math.toDegrees(Math.atan(tanAzimuth));
azimuth = (azimuth + 360) % 360;
if (raHour < 12 && azimuth > 0 && azimuth < 90) {
azimuth += 180;
} else if (raHour > 8 && raHour < 18 && azimuth > 270 && azimuth < 360) {
azimuth -= 180;
}
//System.out.println(azimuth);
System.out.println("Name\t" + name);
System.out.println("RA\t" + object_Rekt + "\tAzimuth\t" + azimuth);
System.out.println("Dek\t" + object_Dekl + "\tHöhe\t" + altitude);
System.out.println("");
}
}