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

Climate: Ocean currents #4

Open
Flokey82 opened this issue Jan 17, 2023 · 4 comments
Open

Climate: Ocean currents #4

Flokey82 opened this issue Jan 17, 2023 · 4 comments

Comments

@Flokey82
Copy link
Owner

Might work similar to global trade winds to a degree where the major streams point the same direction. HOWEVER: There are counter-streams at the borders of the streams.

See: https://en.wikipedia.org/wiki/Ocean_current

There is some interesting work by for-h-in-hexes on that topic:
https://forhinhexes.blogspot.com/search/label/Currents

In theory, we can initialize a vector field similar to the global wind vectors, then walk the currents until we hit land, then walk our way back when the ocean currents are deflected by landmasses. Then we interpolate the vector field using the inverse distance weighted something-something.
https://en.wikipedia.org/wiki/Inverse_distance_weighting

@voidshard
Copy link
Collaborator

I have something hacky that

  • builds a voronoi diagram using points only in the ocean
  • throws away paths that cross land
  • divides the planet into Northern/Southern hemispheres
  • divides each hemisphere into vertical slices
  • for each slice finds a path (if possible) between the pole & equator
  • alternates between making the path 'hot' (carrying warm water toward the pole) or 'cold' (carrying cold water towards the equator)

Just a thought.

@Flokey82
Copy link
Owner Author

That's a pretty smart idea... kinda like a mix of pathfinding and how water flux works when you find the downhill neighbor for each point to chart the flow of rivers?

If you alternate the direction and flip the sort order, the currents would start circulating... Clever idea. Would be worth a look :) It might be also a lot faster than the vector based approach. My usual way of doing it would be to implement both approaches in parallel using two different properties in the structs and then just comparing which one works best. I think your suggestion, if there is not something obvious that we're missing, should be the solution causing the least issues, since there is way less math involved where things could go wrong :)

@voidshard
Copy link
Collaborator

I tried a few approaches and this was the least awful I found that was fairly simple to compute 😄 I'm sure there are cleverer ways but eh 🤷‍♂️

The main issues;

  • Reusing paths. I don't think (??) it makes sense for currents to flow over each other .. although in the case of cold water (should be deeper?) and hot water (shallower?) it actually might be possible .. my high school physics says it makes sense, but then I was never that good at physics
  • The inability to form a current because the land just happened to cross an entire slice .. technically this isn't an issue per se, since if there's no ocean then there's no ocean currents, but it can make for unequal currents in the rest of the oceans -- although if we modelled current strength we could simply infer that the one (say) cold current flowing downward carried more water than the two carrying hot water flowing upward.

@Flokey82
Copy link
Owner Author

Yeah, one way or another, the currents in the top layer are the most important anyway. :) So I think it's safe to disregard the third dimension. I was also able to get away with the global winds to only flow in two dimension :D

Well, in theory you can sort all regions from north to south and south to north and use a queue to work off all ocean regions, so if you don't reach all ocean regions in the first pass, you just repeat the process for all regions (points) that remain unvisited after each pass or so until you run out of tries or the queue is empty :) If I understand it correctly... I'd have to do a sketch on a napkin to be sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants