Board index FlightGear Development

Ephemeris Sun

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Ephemeris Sun

Postby Necolatis » Wed Dec 21, 2016 9:21 pm

So how does ephemesis/sun/local work?

Is it a vector in geocentric coord system to the sun? And if so, is it always a unit vector?
Last edited by Necolatis on Wed May 31, 2017 6:46 am, edited 1 time in total.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2047
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Ephemesis Sun

Postby Thorsten » Thu Dec 22, 2016 6:14 am

If my memory doesn't deceive me, pretty much yes - it's a unit vector in (xyz) FG-world coordinates (earth co-rotating coordinate system also utilized by geo.nas) which points towards the sun.

What problem are you trying to solve? I suppose I have code for most pointing and tracking problems somewhere...
Thorsten
 
Posts: 11375
Joined: Mon Nov 02, 2009 8:33 am

Re: Ephemesis Sun

Postby Necolatis » Thu Dec 22, 2016 7:28 am

I just thought the heat seeking missiles should be able to lock onto the sun once in a while, especially the older kind.

Thank you for the confirmation, I just take the vector then and multiply it with a big factor, and add it to the aircraft position, then looking at that new position should be approx same as looking at the sun I reckon.

Hmm, you don't happen to have how to take a position, pitch, heading and then a distance away in the direction of the pitch and heading to get a new position (in FG-world coords)? I managed to do the opposite, to get the pitch from one position to another, but that other way around has eluded me.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2047
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Ephemesis Sun

Postby Thorsten » Thu Dec 22, 2016 8:21 am

Thank you for the confirmation, I just take the vector then and multiply it with a big factor, and add it to the aircraft position, then looking at that new position should be approx same as looking at the sun I reckon.


The missile has a workd pointing vector (I guess this ought to be the velocity vector to a good approximation). You can simply normalize it and dot this into the sun vector to see whether the seeker is sun-pointed.

Here's the code fragment checking whether the star tracker camera of the Shuttle point sunward and needs to close shutter:

Code: Select all
   var sun_vec = [getprop("/ephemeris/sun/local/x"), getprop("/ephemeris/sun/local/y"), getprop("/ephemeris/sun/local/z")];

   var sun_angle_to_tracker = SpaceShuttle.dot_product(me.world_pointing_vec, sun_vec);

   #print (sun_angle_to_tracker);

   if ((me.manual == 0) and (sun_angle_to_tracker > 0.93))
      {me.shutter = "CL"; return;}
   else
      {me.shutter = "OP";}


Hmm, you don't happen to have how to take a position, pitch, heading and then a distance away in the direction of the pitch and heading to get a new position (in FG-world coords)?


Near zone (i.e. assuming Earth is flat) or far zone (i.e. more than ~150 km distance and curvature matters)?

The near zone is easy, something like

Code: Select all
pos.apply_course_distance(heading, distance * math.cos(pitch_rad));
pos.set_alt(pos.alt() + math.sin(pitch_rad) * distance);



(depends a bit on whether distance is the actual distance (i.e. including vertical component), distance along earth curvature, distance neglecting curvature,...)
Thorsten
 
Posts: 11375
Joined: Mon Nov 02, 2009 8:33 am

Re: Ephemesis Sun

Postby Necolatis » Thu Dec 22, 2016 4:41 pm

Thank you, I think your code is smarter. To get the me.world_pointing_vec could bring me some trouble though.

Ah, I meant with curvature, but if it doesn't matter up till 150 Km then I can do without. Thanks. :)
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2047
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Ephemesis Sun

Postby Thorsten » Thu Dec 22, 2016 5:50 pm

To get the me.world_pointing_vec could bring me some trouble though.


Like I said, for a heat-seeker it's likely forward, so you can use the velocity vector in world coords (I assume you have that?) as a viable proxy - the deviation frame by frame isn't going to be large.
Thorsten
 
Posts: 11375
Joined: Mon Nov 02, 2009 8:33 am

Re: Ephemesis Sun

Postby Necolatis » Thu Dec 22, 2016 5:55 pm

I don't right now actually, I use pitch and heading, but I just came to think that its easy to get, so nevermind what I said, I'll get it. :)
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2047
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Ephemesis Sun

Postby Thorsten » Fri Dec 23, 2016 7:35 am

To get the me.world_pointing_vec could bring me some trouble though.


Should you ever need it:

Aircraft/SpaceShuttle/Systems/pointing.xml

1.500 lines of JSBSim computing the body vectors of the craft in FG world, inertial and LVLH coordinate systems as well as converting pitch, yaw and roll into inertial coordinate pitch, yaw and roll.

I believe you ought to be ale to just include the file without dependencies into any JSBSim craft.

Aircraft/SpaceShuttle/Nasal/rel_orbital.nas

There's the functions orientTaitBryan and orientTaitBryanPassive which take a body axis vector and pitch, yaw and roll as input and spit out the rotated vector given the attitude in FG coordinates - you can always use this to construct a pointing vector for any axis given your attitude from Nasal with this.

(If you feed it inertial pitch, yaw and roll from the pointing routines it will also give you an inertial pointing vector - though you're probably happy with earth co-rotating coordinates...)
Thorsten
 
Posts: 11375
Joined: Mon Nov 02, 2009 8:33 am

Re: Ephemesis Sun

Postby Necolatis » Fri Dec 23, 2016 8:57 pm

Very nice, thanks. :)
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2047
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10


Return to Development

Who is online

Users browsing this forum: AhrefsBot [Bot] and 1 guest