Expressions: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(start document <expression> element)
 
(FPE checks)
Line 3: Line 3:
Expressions are a feature of the SimGear library and provide a nice way of implementing complex math formulas using XML syntax.
Expressions are a feature of the SimGear library and provide a nice way of implementing complex math formulas using XML syntax.
They are supported in many systems within the FlightGear code.
They are supported in many systems within the FlightGear code.
'''Beware:''' Expressions do not check if your math creates floating point exceptions, like division by zero, square root of a negative number etc.


== Usage ==
== Usage ==

Revision as of 21:47, 16 December 2010

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.

General

Expressions are a feature of the SimGear library and provide a nice way of implementing complex math formulas using XML syntax. They are supported in many systems within the FlightGear code. Beware: Expressions do not check if your math creates floating point exceptions, like division by zero, square root of a negative number etc.

Usage

Expressions are supported in

Sample Expressions

This is a sample expression for c = sqrt(a*a + b^2)

<expression>
  <sqrt>
    <sum>
      <product>
        <property>/value/a</property>
        <property>/value/a</property>
      </product>
      <pow>
        <property>/value/b</property>
        <value>2</value>
      </pow>
    </sum>
  </sqrt>
</expression>

Supported elements

<acos>
<asin>
<atan>
<ceil>
<cos>
<cosh>
<exp>
<floor>
<log>
<log10>
<rad2deg>
<sin>
<sinh>
<sqrt>
<tan>
<tanh>
<atan2>
<div>
<mod>
<pow>
<value>
<property>
<abs> (same as fabs)
<sqr>
<clip>
<div>
<mod>
<sum>
<difference> (same as dif)
<product> (same as prod)
<min>
<max>
<table>