public CartesianCoords EquatorialToEclipticCartesian(double obl_ecl) { return(new CartesianCoords( x, y * StarMath.Cos_d(-obl_ecl) - z * StarMath.Sin_d(-obl_ecl), y * StarMath.Sin_d(-obl_ecl) + z * StarMath.Cos_d(-obl_ecl))); }
public CartesianCoords ToCartesian() { return(new CartesianCoords( radius * StarMath.Cos_d(longitude) * StarMath.Cos_d(latitude), radius * StarMath.Sin_d(longitude) * StarMath.Cos_d(latitude), radius * StarMath.Sin_d(latitude) )); }
public CartesianCoords ToCartesian() { var ra_d = rightAscention * StarMath.hours2deg; return(new CartesianCoords( radius * StarMath.Cos_d(ra_d) * StarMath.Cos_d(declination), radius * StarMath.Sin_d(ra_d) * StarMath.Cos_d(declination), radius * StarMath.Sin_d(declination) )); }
public HorizontalCoords ToHorizontal(GeographicCoords geographicCoords, double localSiderealTime) { double ha = (localSiderealTime - rightAscention) * StarMath.hours2deg; double x_sid = StarMath.Cos_d(ha) * StarMath.Cos_d(declination); double y_sid = StarMath.Sin_d(ha) * StarMath.Cos_d(declination); double z_sid = StarMath.Sin_d(declination); double x_hor = x_sid * StarMath.Sin_d(geographicCoords.latitude) - z_sid * StarMath.Cos_d(geographicCoords.latitude); double y_hor = y_sid; double z_hor = x_sid * StarMath.Cos_d(geographicCoords.latitude) + z_sid * StarMath.Sin_d(geographicCoords.latitude); double az = StarMath.Atan2_d(y_hor, x_hor) + 180; double alt = StarMath.Atan2_d(z_hor, Math.Sqrt(x_hor * x_hor + y_hor * y_hor)); return(new HorizontalCoords(alt, az)); }
public static void UpdateElements(Astrobody body, double day) { var el = body.orbitalElements; el.N = StarMath.WrapDeg(body.constants.N_offset + body.constants.N_scalar * day); el.i = StarMath.WrapDeg(body.constants.i_offset + body.constants.i_scalar * day); el.w = StarMath.WrapDeg(body.constants.w_offset + body.constants.w_scalar * day); el.a = StarMath.WrapDeg(body.constants.a_offset + body.constants.a_scalar * day); el.e = StarMath.WrapDeg(body.constants.e_offset + body.constants.e_scalar * day); el.M = StarMath.WrapDeg(body.constants.M_offset + body.constants.M_scalar * day); //CALCULATE SECONDARY ELEMENTS el.L = StarMath.WrapDeg(el.N + el.w + el.M); double E0 = el.M + StarMath.rad2deg * el.e * StarMath.Sin_d(el.M) * (1 + el.e * StarMath.Cos_d(el.M)); double E1 = 0; do { double temp = E0; E0 = E1; E1 = temp - (temp - StarMath.rad2deg * el.e * StarMath.Sin_d(temp) - el.M) / (1 - el.e * StarMath.Cos_d(temp)); // console.log(`${planetType} ecc diff: ${Math.abs(E1 - E0)}`); }while (Math.Abs(E1 - E0) > 0.005); el.E = E1; el.x = el.a * (StarMath.Cos_d(el.E) - el.e); el.y = el.a * Math.Sqrt(1 - el.e * el.e) * StarMath.Sin_d(el.E); el.r = Math.Sqrt(el.x * el.x + el.y * el.y); el.v = StarMath.WrapDeg(StarMath.Atan2_d(el.y, el.x)); //is StarMath.WrapDeg nessecary? ie is negative bad? el.unpertubatedEclitpticCart.x = el.r * (StarMath.Cos_d(el.N) * StarMath.Cos_d(el.v + el.w) - StarMath.Sin_d(el.N) * StarMath.Sin_d(el.v + el.w) * StarMath.Cos_d(el.i)); el.unpertubatedEclitpticCart.y = el.r * (StarMath.Sin_d(el.N) * StarMath.Cos_d(el.v + el.w) + StarMath.Cos_d(el.N) * StarMath.Sin_d(el.v + el.w) * StarMath.Cos_d(el.i)); el.unpertubatedEclitpticCart.z = el.r * StarMath.Sin_d(el.v + el.w) * StarMath.Sin_d(el.i); // el.eclipticSphere = el.eclitpticCart.ToEcliptic(); // el.eclipticSphere.longitude = StarMath.WrapDeg(el.eclipticSphere.longitude)//nesecary? }