SG files and new editing tools
(05-07-2023, 07:13 AM)Dennis Wrote: g[1]=2*y[0]+tg(i[0])+tg(i[1])-2*y[1]
g[2]=3*y[1]-3*y[0]-2*tg(i[0])-tg(i[1])
g[3]=tg(i[0])
where y is the altitude divided by the sector length, i is the grade, the indices 0 and 1 refers to the start and the end of the sector

The math behind it is attached. I didn't clean it up.
Thanks for working out this math. When you say that i is the grade, is that the value that appears in the SG file, the angle in degree or radian, or some other number?

Edit: While investigating this, I found that the grade value in the SG file is:

Grade per SGE (in degrees) * pi/180 * 8192, rounded to the nearest integer

I believe 8192, which is 2^13, was chosen as a multiplier to make sure the value within the SG file would be an integer
Reply
(05-08-2023, 06:22 AM)checkpoint10 Wrote: When you say that i is the grade, is that the value that appears in the SG file, the angle in degree or radian, or some other number?
It's an angle, and in the calculation, you need only the tangent of it. You can use the unit you want.... better, the unit, your calculator wants.
Reply
Excited to say that I successfully used Dennis's formulas to recalculate the TRK grade values from an SG.

First, it is important to note that all the grade and altitude values in the SG file are for the end of a section. The values in TRK file are for the beginning of the section, so compared to the SG, they are shifted to the next section.

The values i[0] and i[1] in Dennis's formulas can be calculated very simply from the SG file as grade/8192.

The only other extra step when using Dennis's formulas is that you need to multiply each of the results by the length of the section.
Reply
I think there is only one mystery left in the TRK file and that is the 9th value in the Section Data:

In post 69 I describe this as follows (see bold below):

Part 6: Section data
Each section may be either a straight line or a curve, and the type is determined by the first value. The purpose of the 7 subsequent values depend on whether it’s a line or curve.

If type is line:
0 - Type (equals 1)
1 - DLONG at start of section
2 - Section length in 500ths
3 - Starting heading
4 - Cosine of heading angle
5 - Sine of heading angle
6 - Cosine of right normal angle (i.e. if the track direction is north, this will be the east direction; possibly used to calculate the location of track edges)
7 - Sine of right normal angle
8 - Unknown (seems to be always 1073741824 on flat ground, a slightly different number when altitude changes). I suspect this number should be thought of as the difference to 1073741824, because that would allow you to deal with more manageable numbers. My other guess is that it has to do with the radius of the circle that forms the heading angle.

========

1073741824 is 2^31 / 2 and I still think it has something to do with elevations and it seems to be greater when there is a bigger slope. The issue with this theory is that there are multiple height lines but only one of these values in each track section. Could it be referring to the altitude of the track centerline? But if so, then why is it only calculated for straight sections?

I have checked the notes from BB&B and Nigel P from over 20 years ago but this value was not explained.
Reply
For me, it looks like an angle. 1073741824 is elsewhere 90°. You have already the heading angle and the normal angle, only the altitude angle is missing. Let's say, the nadir is 0°, then the horizontal plane is 90°, and 1° uphill would be 91°=1085672289. I didn't check the data, it's just an idea.
Reply
(05-16-2023, 03:30 PM)Dennis Wrote: For me, it looks like an angle. 1073741824 is elsewhere 90°. You have already the heading angle and the normal angle, only the altitude angle is missing. Let's say, the nadir is 0°, then the horizontal plane is 90°, and 1° uphill would be 91°=1085672289. I didn't check the data, it's just an idea.

I examined these numbers at Detroit since I have the xsects the same on both sides so it might be easier to analyze. I think you're right, the numbers appear to be angles and has something to do with the slope at some point in the section between the beginning and end. I think the number is the cosine of the angle but since it doesn't seem to care whether it goes uphill or downhill, I am wondering if it has to do with figuring out the section length when viewed from above.
Reply
(05-16-2023, 05:33 AM)checkpoint10 Wrote: If type is line:
0 - Type (equals 1)
1 - DLONG at start of section
2 - Section length in 500ths
3 - Starting heading
4 - Cosine of heading angle
5 - Sine of heading angle
6 - Cosine of right normal angle (i.e. if the track direction is north, this will be the east direction; possibly used to calculate the location of track edges)
7 - Sine of right normal angle
8 - Unknown (seems to be always 1073741824 on flat ground, a slightly different number when altitude changes). I suspect this number should be thought of as the difference to 1073741824, because that would allow you to deal with more manageable numbers. My other guess is that it has to do with the radius of the circle that forms the heading angle.
Update, I am making a special test track to experiment with altitudes and grades. I now believe that the values 4 and 8 are related, because if I make just a simple alteration to the altitude, then both values change. I don't remember why I said previously that value 4 was a cosine of the heading but now I will have to do some more rigorous testing to find out what it really is.

One theory I have is that all the angles represent some kind of 3D vector which would explain why sometimes the vector points up or down.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)