shukob/CelestialUtil

Distance to sun and moon

begiljen opened this issue · 11 comments

Is it possible to extract the distance to the sun and moon? The method astoronoimcalUnitFromEarthAtDate might do this? But it is not implemented yet it seems.

Hi,

the average astronomical unit(AU) from the earth to the sun is 1, as it is the definition.
As it's orbital is almost circle, the number of significant digits for that approximation is about 5, so below that accuracy distance from earth to the sun is almost 1, but it can be computed in more accuracy, I will check.

I will also check the approximation formula for the distance from the earth to the moon.
Will work on them this weekend, but it may require more time.

Thank you : )

Great!

I think the distance to the sun varies between aprox 147 mill. km (periapsis) to 152 mill km (apoapsis), if I understand it correctly (approx 3%).

Thanks for looking into it :)

You are right! I was wrong...
The distance is of 3 significant units.

Hi, I found that these are already almost implemented, so made it work as expected.

  • For the moon and other objects, geocentric distance is calculated using parallax.
  • For the sun, geocentric distance itself is calculated and parallax is calculated using it.

Please check the behavior when you have time?

Thank you : )
Shunpei

Sorry, distance to the moon is wrong and should be corrected.

Confirmed that results are consistent in terms of decade.

Thanks for the update!

I've tested it, and I'm getting good values, both on moon and sun distance.

There is a minor bug in the code though:
The method apparentElevationAtDate is still calling equatorialHorizontalParallaxAtDate with inLocation (but location is removed from the definition).

-(double)apparentElevationAtDate:(NSDate *)date inLocation:(CLLocationCoordinate2D)coordinate{
double elevation = [self elevationAtDate:date inLocation:coordinate];
return elevation + [self atmosphicReflactionForElevation:elevation] - [self equatorialHorizontalParallaxAtDate:date inLocation:coordinate];
}

Hi,

thanks for pointing me the bug.
I've updated : )

Thanks m8, everything is working now! Greatly appreciated :)

Good to hear that! : ) Thank you!

Parallax calculation for the sun was wrong and is corrected.