slowe / VirtualSky

A browser-based planetarium that can be customised and embedded in web pages.
http://slowe.github.io/VirtualSky/
245 stars 94 forks source link

draw satellite orbit #87

Open hmovahedim opened 2 years ago

hmovahedim commented 2 years ago

Hello How can i draw satellite orbit from this orbital element(TLE) ?

meNeither commented 2 years ago

You have to do it yourself. To calculate x and y position via radec2xy, you need azimuth and elevation (to get the right ascension and declination via azel2radec). This in turn can be calculated from the TLE using satellite.js or orb.js.

For a complete implementation, have a look at starlitter.info and my messy source code starting from line 2110.

hmovahedim commented 2 years ago

You have to do it yourself. To calculate x and y position via radec2xy, you need azimuth and elevation (to get the right ascension and declination via azel2radec). This in turn can be calculated from the TLE using satellite.js or orb.js.

For a complete implementation, have a look at starlitter.info and my messy source code starting from line 2110.

Thank you. But how can i draw line with x and y position in virtualsky ?

michealroberts commented 2 years ago

Hi @hmovahedim You need to ascertain the RA and dec values for whatever object you need (the current position would be for new Date()). The trick to getting the "orbital path" would be to extend this datetime to prior and future datetimes ... for whatever time span is appropriate.

For example, if your satellite is geostationary ... it won't have this. So you don't need to worry. However, if the satellite orbits Earth, say once every 90-93 minutes ... extend your x and y calculation for plus / minus 45 - 46.5 minutes.

Does that make sense?

slowe commented 2 years ago

Hi @hmovahedim there isn't a simple way for you to do this because it isn't trivial.

As has been said, you'd have to do a lot of the work yourself. You'll need to know the ins and outs of TLEs and the relevant maths for orbital calculations. Parallax is likely to be much more relevant for such close objects as satellites so, for me, this is very unlikely to be trivial.

hmovahedim commented 2 years ago

I can calculate RA and DEC so how can i draw line with RA and DEC ?

slowe commented 2 years ago

@hmovahedim You can't draw a line with one point - you'll need at least two points for any meaningful line. There isn't a good simple answer to "draw a line". You will need to implement line drawing yourself. You could start by looking at the method drawConstellationLines. You could adapt that and remember that not everything in that will be appropriate for your purpose. For instance,

posa = this.radec2xy(this.stars[a][2], this.stars[a][3]);

shows an object - posa - being made from RA/Dec coordinates. In the subsequent lines you can then see how posa and posbare used withmoveToandlineTo` to draw/update a line segment using .

You'll also need to make sure your new function gets called in drawImmediate so that it actually runs. Some other things to consider: