Giter VIP home page Giter VIP logo

Comments (8)

bcoconni avatar bcoconni commented on June 4, 2024 1

@Mike402
Thanks for this proposal but instead of implementing these functions in C++, I'd rather extend the concept of "template" functions that have been designed for unit conversion (see scripts/unitconversions.xml).

Your functions could then be provided in a kind of library just as the unit conversion functions are.

For that to happen, there is some C++ code to write but that is not on the top of my priorities. If someone volunteer for that, I can provide guidance however.

from jsbsim.

 avatar commented on June 4, 2024

Thanks, that seems reasonable. Can I try it out right away by inserting the snippets in unitconversions.xml or does it depend on C++ in other way than loading an extra xml that would be the new "library"?

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

does it depend on C++ in other way than loading an extra xml that would be the new "library"?

Yes, it needs additional C++ code. At the moment, if you would update unitconversions.xml then you would be unable to use the functions anywhere else than in <output> elements.

from jsbsim.

 avatar commented on June 4, 2024

Also it would be nice to have a "stair" function with adjustable step and transition slope -- which could be used e.g. to represent Geneva drives:

  <fcs_function name="fcs/NPK/instr/UVO[0]/counter/H-100m[1]">
   <function>
    <!-- Geneva drive -->
    <!-- JSBBUG Moves sharply for negative values, because there is no <floor>, and <integer> is used instead! -->
    <sum>
     <!-- Simple step -->
     <integer>
      <product>
       <!-- lower digit -->
       <p>fcs/NPK/instr/UVO[0]/counter/H-100m[0]</p>
       <!-- = 1 / base -->
       <v>0.1</v>
      </product>
     </integer>
     <!-- Transition -->
     <min>
      <v>1.0</v>
      <max>
       <v>0.0</v>
       <product>
        <difference>
         <product>
          <!-- lower digit -->
          <p>fcs/NPK/instr/UVO[0]/counter/H-100m[0]</p>
          <!-- = 1 / base -->
          <v>0.1</v>
         </product>
         <integer>
          <product>
           <!-- lower digit -->
           <p>fcs/NPK/instr/UVO[0]/counter/H-100m[0]</p>
           <!-- = 1 / base -->
           <v>0.1</v>
          </product>
         </integer>
         <!-- transition length, 0.0 to 1.0 -->
         <v>0.9</v>
        </difference>
        <!-- = 1 / transition length -->
        <v>10.0</v>
       </product>
      </max>
     </min>
    </sum>
   </function>
  </fcs_function>

Please note that I have used <integer> instead of the correct <ceiling>, because it is absent in JSBSim -- which makes it work incorrectly for negative inputs. What is intended with <ceiling> is, the transition between -2 and -1 of the output should be between -1.0 and -1.1 of the output and such -- just like 1 and 2 transition between 1.9 and 2.0. That is the function should go on the same way into negative domain, instead of being antisymmetric.

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

From @Mike402 suggested in issue #124 that has been marked as a duplicate of the current issue:

<floor>, <ceiling> and <fmod> would have been very convenient, because their equivalents are very bulky and typo-prone.

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

@Mike402

<floor>, <ceiling> and <fmod> would have been very convenient, because their equivalents are very bulky and typo-prone.

These 3 functions have just been added to <function> via the commit f0d67c8.

from jsbsim.

bcoconni avatar bcoconni commented on June 4, 2024

These 3 functions have just been added to <function> via the commit f0d67c8.

And they are now pushed to FlightGear as well.

from jsbsim.

 avatar commented on June 4, 2024

Wow, thank you, I will try them!

About the requests with sawtooth and stair function: maybe it would be easier to have them in C++, at least for now?

from jsbsim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.