# Equations to Script

Discussion in 'Gauges' started by jdhughen, 19 Jun 2017.

1. ### jdhughen

Joined:
19 Feb 2017
Messages:
137
Country:
All,

I used EXCEL to create some equations based on some regression analysis of some <Nonlinearity> tables. If someone would be so kind to check my work to see if i wrote the scripts correctly. These are all being used for point placement so rounding to nearest whole pixel is added. @Distance is a macro that calcs the distance to touch down along the Glide slope. X=@Distance

Eq (1)
y = -3.382ln(x) + 38.442

Script
(-3.382 (@Distance) ln * 38.442 + .5 + int) (>L:X1, enum)

-------------------------
Eq (2)
Y= 15.39ln(x) - 93.075

Script
(15.39 (@Distance) ln * 93.075 - .5 + int ) (>L:VertOffset, emun)

-------------------------

Eq (3)

y = 322360x^-1.139

Script
(322360 (@Distance) * -1.139 pwr .5 + int ) (>L:X2, enum)

---------------------------

Eq (4)
y = 11187x^-0.622

Script
(11187 (@Distance) * -0.622 pwr .5 + int) (>L:Y2, enum)

-------------------------------
Script
0 (>L:Y1, enum) // Y1 should be = 0

Thanks

Joel

Last edited: 19 Jun 2017
2. ### jdhughen

Joined:
19 Feb 2017
Messages:
137
Country:
UPDATE
I think I miss read the equation. i believe it should be.....

Eq 3)
y = 322360x^-1.139

Script
(322360 (@Distance -1.139 pwr) * .5 + int ) (>L:X2, enum) ????

Eq 4)
y = 11187x^-0.622

Script
(11187 (@Distance -0.622 pwr) * .5 + int) (>L:Y2, enum)

????

Joel

3. ### HereticResource contributor

Joined:
1 Feb 2007
Messages:
5,125
Country:
Note that there can be no parenthesis in XML formatting (except for designating variables).

And rounding to the nearest whole number is best achieved with "ceil" instead of "int".

4. ### jdhughen

Joined:
19 Feb 2017
Messages:
137
Country:
First I replaced @Distance with L:distance which is evaluated earlier in the code. I looked at the FSX SDK and it says the "Ceil" rounds up, and Int rounds down. So I guess to use "Ceil" to round it would be " .5 - ceil " ? What about "near" does that work in FS9 ? The SDK says "near" rounds without having to +-.5 ??

So after removing () with these. do they look valid ?

1) -3.382 (L:distance, feet) ln * 38.442 + near (>L:X1, enum) OR
(L:distance, feet) ln -3.382 * 38.442 + near (>L:X1, enum)

2) 15.39 (L:distance, feet) ln * 93.075 - near (>L:VertOffset, emun) OR
(L:distance, feet) ln 15.39 * 93.075 - near (>L:VertOffset, emun)

3) 322360 (L:distance, feet) -1.139 pwr * near (>L:X2, enum) OR
(L:distance, feet) -1.139 pwr 322360 * near (>L:X2, enum)

4) 11187 (L:distance, feet) -0.622 pwr * near (>L:Y2, enum) OR
(L:distance, feet) -0.622 pwr 11187 * near (>L:Y2, enum)

thanks
Joel

Last edited: 20 Jun 2017
5. ### HereticResource contributor

Joined:
1 Feb 2007
Messages:
5,125
Country:
Both variants of each equatio look valid to me.