Jump to content

looking for help getting terminator projection onto a map like kerbalmaps.com


Drew Kerman

Recommended Posts

Anyone willing to help save me some trouble working through all the math? I want to be able to do this for bodies in the game. I have a website that uses the same library that runs kerbalmaps.com and can modify the Leaflet application to create terminators if I knew how to calculate and project them onto the map. I have this plugin to start with but the author has already told me he is too busy to assist with converting it for use with KSP bodies

Link to comment
Share on other sites

There are several ways to do this. Lets start with a simple question. Do you want an equation for the curve that marks terminator itself, or do you want to tell for each pixel on the map if it should be drawn light or dark?

Also, which projection are you using for the map? Simple equirectangular projection or something like Mercator?

Link to comment
Share on other sites

All bodies have their spin axes aligned the same way. Another way of thinking of it is they all share the same North Star. However the orbital inclinations vary and that allows the spin axes to be tilted relative to the orbital plane.

Link to comment
Share on other sites

On 29.03.2016. at 2:16 PM, cantab said:

In the stock system, on most bodies the terminator will be nearly parallel to the lines of longitude. Moho will be the biggest exception.

Kerbol is a point-like source of radiation, not a disk, therefore Moho will not be an exception.

Link to comment
Share on other sites

Ideally I would like to do a proper calculation so I could draw the terminator like this (I assume Moho would look similar with a slightly more dark/light areas at the poles depending on its mean anomaly):

twjIuSO.png

But I wouldn't be averse to just fudging it and doing this (which I understand how to calculate since I know the starting rotation of the bodies):

UDNwNf3.png

Edited by Gaiiden
Link to comment
Share on other sites

15 minutes ago, Gaiiden said:

Ideally I would like to do a proper calculation so I could draw the terminator like this (I assume Moho would look similar with a slightly more dark/light areas at the poles depending on its mean anomaly):

twjIuSO.png

But I wouldn't be averse to just fudging it and doing this (which I understand how to calculate since I know the starting rotation of the bodies):

UDNwNf3.png

The first one assumes an axial tilt. The Earth's projection looks like that but it changes over time.

Link to comment
Share on other sites

6 hours ago, Gaiiden said:

even without the tilt though wouldn't the curve still happen near the poles?

I don't think so. In that projection the North Pole is in its longer night part (on Earth it's 6 months of night at some areas).

The geoscape of the game xenonauts is pretty cool at showing the effect.

Edited by Bill Phil
Link to comment
Share on other sites

ok here's what I have so far:

bXR0fBP.png

All I'm missing right now is the proper sun position. Here's what I'm currently doing:

initialRotationDegree - (((currentTime / siderealRotationPeriod) % 1) * 360)

so I get a fraction of the number of times the planet has rotated and then use that to see how far along the circle it has traveled from its starting position.

currLng = -90 - (((66975144 / 21549.425183090) % 1) * 360);
if (currLng < -180) { currLng += 360; }

the initialRotation and siderealRotationPeriod values I'm using are taken from the game via KSPTOT, and the currentTime value I'm using corresponds to sunrise at KSC (as in, when the sun is just visible over the horizon). Then I convert it to a value between -180 <=> 180 for display on the map.

As you can see, sunrise is nowhere near the KSC by my calculations.

I think I'm not factoring in the body's position in its orbit around the sun?

Edit: Oops! I originally had the longitude for the sun's initial position at 90, but then I realized the body started rotated 90 degrees at the start of the game which means the sun would be 90 degrees west of the meridian. Still, that correction doesn't make things totally right

Edit2: Damn, I originally was saying initialRotationDegree + (((currentTime / siderealRotationPeriod) % 1) * 360), which meant the sun was moving west to east *facepalm* unfortunately that didn't fix things completely either

Edited by Gaiiden
Link to comment
Share on other sites

ok, I think I have it - I should be using the solar day time (21600) instead of the sidereal time. I actually previously did try to use the solar day time and didn't get a proper result because it was before I took into account the two mistakes I had also made in my calculations that I point out in the edits for the previous post. Here's the result:

16NYBA3.png

m0uyVWl.png

So yea. Wheeeee!!! Thx to all for the guidance, much appreciated

Actually I do have one more question - the moons in the KSP wiki don't have values for solar days. Are their solar days the same as their sidereal rotation period? Or has no one just bothered to calculate their solar days?

Oh and you can all check it out yourself here.

Edited by Gaiiden
Link to comment
Share on other sites

Sorry, I've been busy throughout the week. Do you still care about getting this to work for non-zero inclination, or did you ever only need this to work for Kerbin?

Solar days on moons can get pretty complicated in general, but if all of the inclinations nearly match, id est, most of the rotations are nearly in the same plane, they work pretty much the same as for the planets. Except the orbital period you care about is still that of the planet, while sidereal rotational period is taken from the moon. The general formula is TD = 1/(1/TS - 1/TO), where TD is solar day, TS is sidereal rotation period, and TO is the orbital period. This assumes that all of the rotations are in prograde. If one of them is retrograde, flip the sign of corresponding T. Likewise, if TD you get is negative, sunrise will happen on the "wrong" side of the moon/planet.

Link to comment
Share on other sites

12 hours ago, K^2 said:

Sorry, I've been busy throughout the week. Do you still care about getting this to work for non-zero inclination, or did you ever only need this to work for Kerbin?

Solar days on moons can get pretty complicated in general, but if all of the inclinations nearly match, id est, most of the rotations are nearly in the same plane, they work pretty much the same as for the planets. Except the orbital period you care about is still that of the planet, while sidereal rotational period is taken from the moon. The general formula is TD = 1/(1/TS - 1/TO), where TD is solar day, TS is sidereal rotation period, and TO is the orbital period. This assumes that all of the rotations are in prograde. If one of them is retrograde, flip the sign of corresponding T. Likewise, if TD you get is negative, sunrise will happen on the "wrong" side of the moon/planet.

thanks for the equation!

I only need this working for Kerbin for starters, but eventually I'll want it for any and all bodies. I'm starting to question though whether it's worth taking the orbital inclination into account if the effect isn't going to be all that big a deal really. I would be happy with the simple approximation I have now.

Link to comment
Share on other sites

Inclinations will matter a lot for some bodies in KSP. What you really want to do is project a great circle corresponding to real terminator onto a map. I'm going to edit in a brief walk-through on how to handle this in general.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...