xml math functions

bomber
Posts: 1379
Joined: Mon Nov 30, 2015 3:40 pm

xml math functions

Postby bomber » Fri Nov 11, 2016 7:44 pm

 sum (takes n arguments)

 difference (takes n arguments)

 product (takes n arguments)

 quotient (takes 2 arguments)

 pow (takes 2 arguments)

 exp (takes 2 arguments)

 abs (takes n arguments)

 sin (takes 1 arguments)

 cos (takes 1 arguments)

 tan (takes 1 arguments)

 asin (takes 1 arguments)

 acos (takes 1 arguments)

 atan (takes 1 arguments)

 atan2 (takes 2 arguments)

 min (takes n arguments)

 max (takes n arguments)

 avg (takes n arguments)

 fraction (takes 1 argument)

 mod (takes 2 arguments)

 random (Gaussian random number, takes no arguments)

 integer (takes one argument)

I thought it would be a good idea as the manual is pretty sketchy as to what these all do to try and understand them...

I'm short on understanding of these


 mod (takes 2 arguments)
 integer (takes one argument)
 fraction (takes 1 argument)
 exp (takes 2 arguments)

any ideas ?
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchell

User avatar
IAHM-COL
Posts: 6455
Joined: Sat Sep 12, 2015 3:43 pm
Location: Homey, NV (KXTA) - U.S.A
Contact:

Re: xml math functions

Postby IAHM-COL » Fri Nov 11, 2016 7:57 pm

The module should find the remainder of the division

Example

if you divide 4 / 2 then the module is zero
(or 4%2= 0)

if you divide 2/4 then the module is two
(or 2%4 = 2)


You will see it clearer if you try per example 11/2
you can divide the first 10 completely (with no remainder left)
as 10/2 is 5. but the other 1 left cant be fully divided,.
so you express like this

10/2 + 1/2

That one left is the remainder (the part you couldn't fully divide) and thus

11%2 should return you 1


Another example for final clarity

try 35/4

So that's 8.75. Because 32 of those 35 can be fully divided and return 8. but the 0.75 results from the remaining 3 being not fully divisible

therefore

35/4 == 32/4 + 3/4
where the 3 is the remainder

35%4 = 3

Now.
Is the xml operator working as such?
https://raw.githubusercontent.com/IAHM-COL/gpg-pubkey/master/pubkey.asc

R.M.S.
If we gave everybody in the World free software today, but we failed to teach them about the four freedoms, five years from now, would they still have it?

User avatar
IAHM-COL
Posts: 6455
Joined: Sat Sep 12, 2015 3:43 pm
Location: Homey, NV (KXTA) - U.S.A
Contact:

Re: xml math functions

Postby IAHM-COL » Fri Nov 11, 2016 8:03 pm

Integer should be the non-decimal part of any real number.

Like
3.5 the integer should return 3

4.532342 the interger should return 4

pi, the integer should return 3

e, the integer should return 2

554.29392 , the integer should return 554

h, the integer should return 0

etc.

Now, does your xml function operate as such?
https://raw.githubusercontent.com/IAHM-COL/gpg-pubkey/master/pubkey.asc

R.M.S.
If we gave everybody in the World free software today, but we failed to teach them about the four freedoms, five years from now, would they still have it?

User avatar
IAHM-COL
Posts: 6455
Joined: Sat Sep 12, 2015 3:43 pm
Location: Homey, NV (KXTA) - U.S.A
Contact:

Re: xml math functions

Postby IAHM-COL » Fri Nov 11, 2016 8:06 pm

exp should give you the exponential function result as in

exp(x,n) is X to the power of n

like in

exp(10,3) should be 1000
exp(2,3) should be 8
exp(4,0.5) should be 2

etc.

Does it work like that?
https://raw.githubusercontent.com/IAHM-COL/gpg-pubkey/master/pubkey.asc

R.M.S.
If we gave everybody in the World free software today, but we failed to teach them about the four freedoms, five years from now, would they still have it?

User avatar
IAHM-COL
Posts: 6455
Joined: Sat Sep 12, 2015 3:43 pm
Location: Homey, NV (KXTA) - U.S.A
Contact:

Re: xml math functions

Postby IAHM-COL » Fri Nov 11, 2016 8:13 pm

Not sure what to think of the operator fraction, but try this

fraction (0.5) should give you 1 and 2 (since 1/2 is 0.5)
fraction (0.1) should give you 1 and 10

I wonder if a xml function can give you 2 output parameters, thou. or how could it handle this?
https://raw.githubusercontent.com/IAHM-COL/gpg-pubkey/master/pubkey.asc

R.M.S.
If we gave everybody in the World free software today, but we failed to teach them about the four freedoms, five years from now, would they still have it?

sanhozay
Posts: 167
Joined: Fri Sep 25, 2015 5:59 pm

Re: xml math functions

Postby sanhozay » Fri Nov 11, 2016 8:24 pm

I think fraction should give you the fractional part of a decimal number, so fraction (1.23) should give 0.23 and fraction(10.7) should give you 0.7.

EDIT: I'm not sure fraction is actually implemented. I can't find it in here:

https://sourceforge.net/p/flightgear/si ... ession.hxx
https://sourceforge.net/p/flightgear/si ... ession.cxx

(And there seem to be some that are not listed on the Wiki, e.g. deg2rad, rad2deg and clip).

bomber
Posts: 1379
Joined: Mon Nov 30, 2015 3:40 pm

Re: xml math functions

Postby bomber » Fri Nov 11, 2016 8:52 pm

Code: Select all

       <fcs_function name="T4T/test/mod">
      <function>
         <mod>
            <value> 35 </value>
            <value> 4 </value>
         </mod>
      </function>
   </fcs_function>

returns 3


Code: Select all

   <fcs_function name="T4T/test/exp">
      <function>
         <exp>
            <value> 2 </value>
            <value> 3 </value>
         </exp>
      </function>
   </fcs_function>

returns 7.389056099


Code: Select all

   <fcs_function name="T4T/test/integer">
      <function>
         <integer>
            <value> 3.142 </value>
         </integer>
      </function>
   </fcs_function>

returns 3


Code: Select all

   <fcs_function name="T4T/test/fraction">
      <function>
         <fraction>
            <value> 3.142 </value>
         </fraction>
      </function>
   </fcs_function>

returns 0.142
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchell

OPFOR77
Posts: 208
Joined: Wed Apr 27, 2016 7:30 pm

Re: xml math functions

Postby OPFOR77 » Fri Nov 11, 2016 9:00 pm

http://jsbsim.sourceforge.net/JSBSim/classJSBSim_1_1FGFunction.html explains all of them with examples.

<mod> is modulo, not module.

<exp> raises "e" to the power of the immediate child element.

<fraction> returns the fractional part of the value of the immediate child element.
OPRF Fighter Jock and Dev

bomber
Posts: 1379
Joined: Mon Nov 30, 2015 3:40 pm

Re: xml math functions

Postby bomber » Fri Nov 11, 2016 9:03 pm

sanhozay wrote:I think fraction should give you the fractional part of a decimal number, so fraction (1.23) should give 0.23 and fraction(10.7) should give you 0.7.

EDIT: I'm not sure fraction is actually implemented. I can't find it in here:

https://sourceforge.net/p/flightgear/si ... ession.hxx
https://sourceforge.net/p/flightgear/si ... ession.cxx

(And there seem to be some that are not listed on the Wiki, e.g. deg2rad, rad2deg and clip).



I think we should first clear up any confusion with those functions supplied by JSBsim alone.... then move on to any traditional xml functions that flightgear provide.

Does that make sense ?

Simon
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchell

sanhozay
Posts: 167
Joined: Fri Sep 25, 2015 5:59 pm

Re: xml math functions

Postby sanhozay » Fri Nov 11, 2016 9:57 pm

Ah, JSBSim functions. I misunderstood. They are documented with examples here:

https://sourceforge.net/p/flightgear/fl ... Function.h


Return to “JSBsim”

Who is online

Users browsing this forum: No registered users and 8 guests