Track Heights in track sections ================================= Author:Adrian Walti height - question preface the following chapters explain the height-question. the calculations found here later got included in the track-editor, so its nomore necessary to unterstand them all. you simply can watch the columns Òcumlative gradientÓ, ÒaltitudeÓ and Òcumlative altitudeÓ in the track-data-table in the track-editor. if both cumlatives are around 0 at the end, the track will work fine. but if you want to understand whats going on, you are invited to read the whole story ... explanations to the sketches 1, 2 and 3. explanations of some of the used terms could be found in the glossary at the end of this note.intro in this file i am talking about how the height-values in the track-data-tables of the track-editor of paul hoad work. most of us are fascinated by driving up and down, so we all want to make tracks, that go up- and downhill. but its not an easy task to understand how it works. we make changes to the height-value and realize changes on the track and we learn how to deal with it. so far so good, but at the end, we realize, that there is something wrong with the track. there is a strange sharp bump near the start/finish line. if we were unlucky, we even noticed one or more huge ramps on the track, that are almost unpassable. so we see, we have to know EXACTLY how it works. the first thing to understand is the height-value. actually as far as i know, it has nothing to do with height. actually its some kind of curvature (german: krŸmmung). if we multiply it with the length-value, we get a gradient-change. at the beginning of the track, we have a certain gradient (of the track), then with any height-value, respectively gradient-change, the gradient changes. it is obvious, that we want the same gradient at both ends of the track, so we have to sum up all the gradient-changes, and this sum has to be (about) 0. this is the first part of the height-question. it concerns the gradient-change. most of you already knew this. if you multiply the sector-length with the sector-height you get the gradient-change. at every sector you enter a height-value other than 0, the gradient of the track changes. this is already described in several track-editing guides. as i mentioned, the most important thing here is: the sum of all gradient-changes has to be 0 at the end. but thats only half the truth. please have a look at sketch 1. it shows simplified side-views of two similar tracks. they both have the same gradient at both ends, but there is a difference anyway. the altitude is not the same at both ends of the second track. now the gp2-graphic-engine connects the ends of the track anyway, and to do so, it someway distorts it (but dont ask me how), and we get a crack, a sharp bump. we also can say: this sharp bump around the s/f-line is an indication of an unequalized altitude level. our second task has to be to equalize the altitude, and this is the main theme of this note. basics first please have a look at sketch 2.

here we have the side-views of two sectors somewhere on a track. the green lines are the sectors. we also see the previous and the following parts of the track. both sectors are in the middle of an uphill section, so the gradient is greater than 0. graph 1), the upper, shows a sector with NO gradient-change, that means with a height-value of 0. the other graph shows a similar sector WITH a gradient-change, that means with a height-value other than 0. please notice the difference between gradient and gradient-change. both sectors have a certain gradient, so both sectors also have a change of the altitude. we see, that there is a change of the altitude whether we have a gradient-change or not. the gradient at the beginning of the sector is an absolute gradient, it is the sum of all gradient-changes up to there. and we know, that at the end of the track this sum has to be 0. but we see, that there is also an altitude-change, and here we come to the point: we also have to sum up this altitude-changes. and at the end this sum has to be 0 too. thats what is meant by an equalized altitude level. so we have to be aware of TWO parameters when changing height-values: -first, the sum of all gradient-changes has to become 0. (thats old news) -second, the sum of all altitude-changes has to become 0. if not, we get the sharp bump. now we know what we want. but the question is how to get it. calculation please have a look at sketch 3.

in green you see again our sector with a gradient-change. the pink line symbolizes the gradient at the beginning of our sector. the blue line means the gradient at the end of our sector. the gradient of the pink-line is the sum of all gradient-changes up to our sector, its the actual gradient. the gradient of the blue-line equals the gradient of the pink-line plus the gradient-change of our sector. the orange-line would symbolize our sector, if the gradient-change would count immediately at the beginning of the sector, which is not the case (and we are happy about that, because there would be a crack). matterfact the gradient changes smooth, way like a bow of a circle. now we want to know the amount of the altitude-change of our sector. as we see in sketch 3, the altitude-change is a combination of the two parts a1 and a2. these two parts we can alculate separately. but before we start calculating things, we want to define some variables: m1: gradient at the beginning of the sector; gradient of the pink line m2: gradient at the end of the sector; gradient of the blue and the orange line md: gradient-change of the sector (length-value * height-value) l: length of the sector (length-value) we calculate a1, this is the easy part. here we go: a1 := m1 * l part a2 is more difficult to see, we start by taking: a4 := md * l this gives us a4 or a2+a3 in sketch 3, the distance from the pink to the orange line. now we want to divide by 2, which gives us a2. a2 := (md * l) / 2 this last sentence is a weak point of my explanation: it is a simplification, an approximation, as we can see in sketch 3. but i guess it is good enough, and i guess geoff crammond also made such a simplification. if the game would have to do all the arcustangessinusarcuscosinus-stuff, that is needed here to calculate the correct a2, it would be much slower. matterfact the divisor 2 is a very close approximation on small gradients, as the mathematicians among us know well. last but not least we have the addition: ad := a1 + a2 and ad is the altitude-change, that we wanted to know. real world application now we can sit down and calculate all our sectors to have a look at the altitude level at the end, and of course its other than 0, so we have to change a height-value here and there, and recalculate the thing, and when we finished it, the first second of eternity already passed. we know, there must be an easier way. well you guessed it: we need a spreadsheet ! i say: you can not do it without a spreadsheet (german: tabellenkalkulation). its hard enough to do it WITH one. in order to understand the further explanations you have to know a little about spreadsheets. if you do not, please first have a look at the getting-started-manual of your spreadsheet-program. let us work with the following columns: identification of the sector A: id B: sector name values read out of the track-data-table of the track-editor C: length-value D: angle-value E: height-value first step calculations: F: gradient-change; C times E G: gradient; here we sum up the FÕs.so we can see the gradient at the end of any sector second step calculations: H: altitude-change; (here we are!); (G plus F/2), then times C I: altitude; here we sum up the HÕs. so we can see the altitude-level at the end of any sector. last but not least: J: id; again (similar to A) now the rows the first row of the spreadsheet is special, because we have to initialize some things. here we go with an example. columns A to E and J do contain values out of the track-data-table of the track-editor, they are not shown in the example. the other columns contain CELL-FORMULAS: F G H I row1 =C1*E1 0 =(F1/2)*C1 =H1 row2 =C2*E2 =G1+F2 =(G1+(F1/2))*C1 =I1+H2 row3 =C3*E3 =G2+F3 =(G2+(F2/2))*C2 =I2+H3 etc. most of all, we are now interested in the columns G and I. column G should be about 0 at the end of the table, say +/- 2 would do fine. at column I you should have about +/- 500. example with numbers: A B C D E F G H I J row1 0 s0 8 0.00 0 0 0 0 0 0 row2 1 s1 3 0.00 5 15 15 22 22 1 row3 2 s2 1 0.00 -3 -3 12 14 36 2 etc. (personally i prefer to divide the altitude-change by 100 in column H, in order to get a more handy number. this way you should get +/-5 at the end.) thats it :) addie walti glossary height-value, length-value with height-value and length-value, or just length, i mean the values out of the track-data-tables in the track-editor. curvature a value that says how strong a curved line changes its direction. gradient gradient means a value that says how steep it goes uphill or downhill. if you would like to know the amount of altitude-change after a certain distance on a road with constant gradient, you multiply the difference with the gradient. gradient-change having a gradient-change means, the steepness changes. if you have a positive gradient-change, it goes steeper uphill, or less steep downhill. if you have a negative gradient-change, it goes less steep uphill, or steeper downhill. by multiplying the length-value and the height-value of a sector you get the gradient-change of this sector. if you want to know the (absolute) gradient at the beginning of a certain sector, you have to sum up the gradient -changes of all the previous sectors. at the end of the track, after the last sector, the sum of the gradient-changes should be about 0. please notice the difference between gradient and gradient-change. altitude, altitude-change with altitude i mean the altitude difference to the start-point of the track. the track starts with altitude 0, then, depending on the height-values of the sectors, the altitude may change. altitude-change is the specific amount of change whithin one sector. at the end of the track, the altitude should be again about 0.