• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX XML COSINUS function

Messages
371
Country
france
Hi,

To define the Vref of the A320, I had only the chart with landing weight and and Speed.

I have define a mathematical function to calculate the Vref according the weight of the Aircraft.

but I need Cosinus function in my function :

So, the COS function in the FSX xml return strange values, that are totally different that my hand calculator.

By reading the SDK, i see : COS (input in radians) . Maybe the explication of hte problem

Do you know if there is a solution to use the real cosinus function in xml gauge ?

I have past 6 hours to find the right formula myselff and now I can use it because the microsoft COSINUS is not standard !!!


The VAPPP of an A320 is :

in classic language :
A320 Vref = ( ( Aircraft weightl(kg) / 1000 ) * 1.757 + ( ( COSINE(Aircraft weight(kg)) / 1000 ) * 50 ) )
 
Last edited:
The Microsoft COS function is indeed 'standard'. Trying to find the cosine of a weight isn't 'standard'.

Radians is a conversion from degrees... a basic geometry definition.

I don't think you can convert a number greater than 359 into radians, but... I could be wrong. :)
 
Do you know if there is a solution to use the real cosinus function in xml gauge ?

Yes, just use it as is, because it works ok as per the SDK.

(angle in radians) cos

I don't know where did you get that VAPPP formula, but COSINE(Aircraft weight(kg)) is not good, unless a weight can be considered an angular unit...

Tom
 
I don't convert number greater than 359 because I divide the weight per 1000.
So , i convert number from 46 to 77.



COSINE in a mathematical function that gives a typical curves. I know that it is used for angles, but what I search is the outline given by COSINE.



Tom, i don't find somewhere my formula. i have concocted this formula alone, because she gives me the perfect curves for the A320 landing VreF.

The A320 Vref is not a linear curve and the COS give the good curves.

this curves :

612689Image3.jpg



I have tried with all the weight by 1000kg block and the result of my function give the right result with less of 1 knot of error, for all weights.

But that's work only with a classic calculator (of my daughter) or the Windows calculator, where the input is a number and not a radian value.

You know, things you can use to do something, even if it was not planned for it. Only the result counts.
it is a typical french behavior with the fact bitching all the time

It does not matter, I tried to find another formula that not use COSINE function.

Thanks


The Microsoft COS function is indeed 'standard'. Trying to find the cosine of a weight isn't 'standard'.

Radians is a conversion from degrees... a basic geometry definition.

I don't think you can convert a number greater than 359 into radians, but... I could be wrong. :)

No, because the microsoft function works only if the input is in radians. So , you can use it only for angle calculation. The standard COSINE function can work with any number for other things that angle calculation.



Francois
 
Last edited:
I don't convert number greater than 359 because I divide the weight per 1000.
So , i convert number from 46 to 77.
Ok, then check the formula you posted:

A320 Vref = ( ( Aircraft weightl(kg) / 1000 ) * 1.757 + ( ( COSINE(Aircraft weight(kg)) / 1000 ) * 50 ) )

It is calculating a COSINE of a (kg) value. I can guess you made a typo here.

COSINE in a mathematical function that gives a typical curves. I know that it is used for angles, but what I search is the outline given by COSINE.

Actually COSINE is a trigonometric function that applies to angles, which can be expressed both in degrees or radians; so again FS is not wrong nor out of standards by using the second unit. The fact that you can use it for other type of calculations doesn't invalidate its real meaning.

Now, it amazes me that you can feel overwhelmed by an issue like the XML cos operator, that needs a source in radians instead of degrees, which is so simple to solve by converting your "degree" values to radians...:confused:
Hint: if you want FS make the conversion itself, check this thread, post #5

http://www.fsdeveloper.com/forum/showthread.php?t=425561

Tom
 
I think you need to review the initial equation.

cos(x) can only vary between +1 and - 1 cyclically as follows

cos(0) = +1
cos(π/2) = 0
cos(π) = -1
cos(3π/2) = 0
cos(2π) = +1

after which it repeats without limit as shown.
 

Attachments

  • Capture.JPG
    Capture.JPG
    39 KB · Views: 485
Ok, then check the formula you posted:

A320 Vref = ( ( Aircraft weightl(kg) / 1000 ) * 1.757 + ( ( COSINE(Aircraft weight(kg)) / 1000 ) * 50 ) )

It is calculating a COSINE of a (kg) value. I can guess you made a typo here.



Actually COSINE is a trigonometric function that applies to angles, which can be expressed both in degrees or radians; so again FS is not wrong nor out of standards by using the second unit. The fact that you can use it for other type of calculations doesn't invalidate its real meaning.

Now, it amazes me that you can feel overwhelmed by an issue like the XML cos operator, that needs a source in radians instead of degrees, which is so simple to solve by converting your "degree" values to radians...:confused:
Hint: if you want FS make the conversion itself, check this thread, post #5

http://www.fsdeveloper.com/forum/showthread.php?t=425561

Tom

I think you need to review the initial equation.

cos(x) can only vary between +1 and - 1 cyclically as follows

cos(0) = +1
cos(π/2) = 0
cos(π) = -1
cos(3π/2) = 0
cos(2π) = +1

after which it repeats without limit as shown.

It is not important. my english is to poor. to explain. my formula worked on a calculator by a result between 0 and 1, this is the reason why I multiple by 50 to create an offset and add this offset to the weight diveide by 1000 faactor of 1.757.

See the curves of the COSINE, not the result ; this is the curve that is important. The same curve the lgiht sensibility of your digital camera sensor (I am a photagrapher).

In france, with call this type of curves " S curve".

Forget my message.


I can't explain well, but that's worked.

I have found a new formula, but with less precision, because she is linear

(A:TOTAL WEIGHT, kilograms) 1000 / 70 + near (>L:Vref,enum)
(L:Vref,enum) 5 + (>L:FMC_VAPP,enum)
(A:AIRCRAFT WIND Z, knots) 45 < if{ (A:AIRCRAFT WIND Z, knots) abs 3 / (>L:Wind_Vref,enum) }
(A:AIRCRAFT WIND Z, knots) 45 >= if{ 15 (>L:Wind_Vref,enum) }

The low weight or hight weight aircraft are not right like my old COS formula, but the error isless than 3 knots in the begin and in the end of the curves.

Center is right.

Forget this message.
 
here is the A320 Vref chart :
http://www.db-online.fr/francois/temp/A320vRef%5b1%5d.pdf


landing weight = 50000kg

50000/1000=50
cos(50)=0.64278
50*0.64278=32.14 this is my offset

50000/1000=50
50*1.757=87.85

87.85 + 32.14 = 119.99 real speed is 118

70000kg
70000/1000=70
cos(70)= 0.3746
0.3746*50=17.101


70000/1000=70
70*1.757=122.99 + 17.101 = 140.091 real speed is 140

you can repeat the operation for all weights, that't works.
Cos gives me the "S curve"

Don't forget, I am a crazy frenchie.
 
It should work if you convert your landing weight/1000 to radians, i.e divide by about 57, then FSX will produce the number you need to form the curve.
 
Francois,

Your original formula, making a little ammend, will work fine :

A320 Vref = ( ( Aircraft weightl(kg) / 1000 ) * 1.757) + ( ( COSINE(Aircraft weight(kg) / 1000) * 50)

I was trying to explain this to you, but seems with no luck..:(

Supposing your ac weight is 55000, you should make

COSINE(55000/1000) = COSINE(55)

but, you must convert 55 from "degrees" to radians.

So, 55 (>L:Converter,degrees) (L:Converter,radians) will do the job and you don't even have to google for a conversion formula :D

Only rest that you build the final XML script.

Tom
 
I'm still puzzled.

As others have said cos() takes radians as it argument but you have allowed for that.

cos(50 deg) = cos(0.87266 rad) = 0.642788 which gives a Vref = 50 * 1.757 + %0 * 0.642788 = 119.99 kt
This agrees closely with the tabulated value of 118 kt given in your attachment.

But

cos(70 deg) = cos(1.22173) = 0.342020 which gives a Vref = 70 * 1.757 + 70 * 0.342020 = 146.93 ktkt
This diverges from the tabulated value of 140 kt. Also you show cos(70 deg) = 0.3746.
and

cos(77 deg) =- cos(1.34903 rad) = 0.22495 which gives a Vref = 77 * 1.757 + 77 * 0.22495 = 152.61 kt
This also diverges from the tabulated value of 147 kt

The attached chart shows variation of Calcuated and Tabulated Vref with weight. (The kinks in the tabulated curve arise because there are duplicate values of weight in kg in the table because it also has weight in lb.)

The chart seems to show a significant divergence between the Calculated and Tabulated values, but that a linear trend-line fits the Tabulated values very closely.

What am I missing?
 

Attachments

  • Capture.JPG
    Capture.JPG
    31.8 KB · Views: 479
What am I missing?

This:

( ( COSINE(Aircraft weight(kg) / 1000) * 50)

50 is a fixed factor.

You are doing instead:

( ( COSINE(Aircraft weight(kg) / 1000) * (Aircraft weight(kg) / 1000))

Tom
 
Francois,

Your original formula, making a little ammend, will work fine :

A320 Vref = ( ( Aircraft weightl(kg) / 1000 ) * 1.757) + ( ( COSINE(Aircraft weight(kg) / 1000) * 50)

I was trying to explain this to you, but seems with no luck..:(

Supposing your ac weight is 55000, you should make

COSINE(55000/1000) = COSINE(55)

but, you must convert 55 from "degrees" to radians.

So, 55 (>L:Converter,degrees) (L:Converter,radians) will do the job and you don't even have to google for a conversion formula :D

Only rest that you build the final XML script.

Tom

I will try tom, I promise you but, I think that the result will not the same, because the range (45 to 70 t) was perfect with the COS in degrees.

I am afraid that the radian conversion change totally the results

If the aircraft has been a 747, my formula hasn't been not work, because, the values will be not in the good range of the COS curve.

But I will try, I promise you.

In final, crazy fdd_fr is not so crazy ;)






I am afraid to do the
 
Ok... I think something needs to be clarified...

All trigonomeric functions are based on angles being in the unit of radian. Radian is simply another unit for an angle, like a degree is.

The fact you can type 40 into a calculator and it returns the cosine of the angle doesn't make what we're telling you wrong. Behind the 'scenes' the calculator is automatically converting your input of degrees to the units of radians and then doing the calculations.

I am puzzled why you can understand the concept of different units such as feet, meters, kilograms, pounds... but degrees and radians don't 'click'.

If you are using the trigonomeric functions on a calculator, your input is expected to be in degree units. If you are using the trigonomeric functions on a computer your input is usually expected to be in radian units.

Even Microsoft's Excel spreadsheet requires the angle's value to be converted from degrees to radians when using it's trig functions.
 
You may take your original formula. The required change is:
COSINE(Aircraft weight(kg) / 1000 * pi /180)
this converts your "degree" value in radians and you get the expected result.
Mike
 
( ( COSINE(Aircraft weight(kg) / 1000) * 50)

50 is a fixed factor.

You are doing instead:

( ( COSINE(Aircraft weight(kg) / 1000) * (Aircraft weight(kg) / 1000))

Tom

Ooops! You are right. I've replotted my graph.

This suggests that a straight line Vref = 65 + 1.075 Weight (1000 kg) would work.

Weight = 45000 kg Vref = 113.38 kt (tabulated 112 kt)
Weight = 50000 kg Vref = 118.75 kt (tabulated 118 kt)
Weight = 70000 kg Vref = 140.25 kt (tabulated 140 kt)
Weight = 77000 kg Vref = 147.78 kt (tabulated 147 kt)


I am afraid that the radian conversion change totally the results

It won't

cos(50 deg) = cos(0.87266 rad) = 0.642788

50 deg * π/180 = 0.07266 radians

You may have been using a calculator that accepts degrees. I have one that defaults to degrees but can be changed to radians.
 

Attachments

  • Capture.JPG
    Capture.JPG
    32 KB · Views: 431
sorry, I assumed that youn know that pi = 3.14159265359. If you use that as suggested then the result is correct.
Mike
 
...

Weight = 45000 kg Vref = 113.38 kt (tabulated 112 kt)
Weight = 50000 kg Vref = 118.75 kt (tabulated 118 kt)
Weight = 70000 kg Vref = 140.25 kt (tabulated 140 kt)
Weight = 77000 kg Vref = 147.78 kt (tabulated 147 kt)

Based on these numbers and a small modification of the scripts in my own panel, I get the following:

Code:
(A:TOTAL WEIGHT, kilograms) 77000 min 45000 max s0 
l0 sqr 0.0000000038 /-/ * l0 0.00156 * + 49.5 + int s1 
(L:Vref,enum) l1 != if{ l1 (>L:Vref,enum) } 
(A:AIRCRAFT WIND Z, knots) 45 min 0 max 3 / int l1 + 5 + s2 (L:Vapp,enum) l2 != if{ l2 (>L:Vapp,enum) }

Vref values are within 0.09 of the target numbers and are converted to integers anyway. Vapp is 1/3 of the headwind up to a maximum of 15 plus Vref plus 5 kts...

Geoff
 
Last edited:
hi everybody,

the Cosine is a success story !

I have not had time to experiment with conversions in radians, because I am trying to debug another part of my code at this moment(managed DME arc and approach data files), but it is planned for this weekend.

I will comeback to you.

Francois
 
Back
Top