Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap longitude in the solver #23

Merged
merged 1 commit into from
Apr 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tawhiri/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def euler(t, lat, lng, alt, model, terminator, dt=1.0):
df = model(t, lat, lng, alt)
lat += df[0] * dt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want to wrap latitude?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I'm trying to work out whether bad things happen at the poles or not.

So models.py#76 is going to go crazy (starts to become a problem when lat ~= 90- 1e-5, I reckon, since then dlng is going to be approaching 180 degrees).

However, this may not be an issue since the longitude circle is so small at the pole that the longitude value doesn’t really… matter (at 90 - 1e-5, on the order of tens of metres radius (am I right?)).

If we are going to handle latitudes at the poles we need to special case lat=90 and avoid dividing by zero on that line; then we need to have some logic to handle flipping the longitude by 180 degrees when it goes over a pole an odd number of times.

This will be quite a few more lines in solver.py, but hopefully since it will only run rarely the cost to our loop is just evaluating one if statement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooor we could not support going directly over the pole?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could disregard that for now and deal with it later. A separate issue, perhaps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good plan.

lng += df[1] * dt
lng %= 360.0
alt += df[2] * dt
result.append((t, lat, lng, alt))
return result