Expressions: Difference between revisions

Jump to navigation Jump to search
21 bytes removed ,  10 September 2013
m
found this old page via {{WIP}} - now a stub
m (Robot: Cosmetic changes)
m (found this old page via {{WIP}} - now a stub)
Line 1: Line 1:
{{WIP}}
{{Stub}}
== General ==
'''Expressions''' (or '''SGExpressions''') 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.
 
'''Beware:''' Expressions do not check if your math creates floating point exceptions (like division by zero conditions, taking the square root of a negative number, etc.). This can cause undefined behavior and may result in NaNs or even [[Cascading Not-a-Number Errors|Cascading NaNs]].


== Usage ==
== Usage ==
Expressions are supported in
Expressions are supported in
* [[Autopilot Configuration Reference#Expressions|Autopilot configuration files]]
* [[Autopilot Configuration Reference#Expressions|Autopilot configuration files]]
* The particle system configuration files
* Particle system configuration files
* Animations (translate, rotate, scale, range, blend)
* Animations (translate, rotate, scale, range, blend)
* The shader technique
* The shader technique
Line 14: Line 14:
== Sample Expressions ==
== Sample Expressions ==
This is a sample expression for c = sqrt(a*a + b^2)
This is a sample expression for c = sqrt(a*a + b^2)
<expression>
<syntaxhighlight lang="xml">
  &lt;sqrt>
<expression>
    &lt;sum>
  <sqrt>
      &lt;product>
    <sum>
        &lt;property>/value/a</property>
      <product>
        &lt;property>/value/a</property>
        <property>/value/a</property>
      &lt;/product>
        <property>/value/a</property>
      &lt;pow>
      </product>
        &lt;property>/value/b</property>
      <pow>
        &lt;value>2</value>
        <property>/value/b</property>
      &lt;/pow>
        <value>2</value>
    &lt;/sum>
      </pow>
  &lt;/sqrt>
    </sum>
&lt;/expression>
  </sqrt>
</expression>
</syntaxhighlight>


== Supported elements ==
== Supported elements ==
&lt;acos&gt;
<syntaxhighlight lang="xml">
&lt;asin&gt;
<acos>
&lt;atan&gt;
<asin>
&lt;ceil&gt;
<atan>
&lt;cos&gt;
<ceil>
&lt;cosh&gt;
<cos>
&lt;exp&gt;
<cosh>
&lt;floor&gt;
<exp>
&lt;log&gt;
<floor>
&lt;log10&gt;
<log>
&lt;rad2deg&gt;
<log10>
&lt;sin&gt;
<rad2deg>
&lt;sinh&gt;
<sin>
&lt;sqrt&gt;
<sinh>
&lt;tan&gt;
<sqrt>
&lt;tanh&gt;
<tan>
&lt;atan2&gt;
<tanh>
&lt;div&gt;
<atan2>
&lt;mod&gt;
<div>
&lt;pow&gt;
<mod>
&lt;value&gt;
<pow>
&lt;property&gt;
<value>
&lt;abs&gt; (same as fabs)
<property>
&lt;sqr&gt;
<abs> <!-- also: fabs -->
&lt;clip&gt;
<sqr>
&lt;div&gt;
<clip>
&lt;mod&gt;
<div>
&lt;sum&gt;
<mod>
&lt;difference&gt; (same as dif)
<sum>
&lt;product&gt; (same as prod)
<difference> <!-- also: dif -->
&lt;min&gt;
<product> <!-- also: prod -->
&lt;max&gt;
<min>
&lt;table&gt;
<max>
<table>
</syntaxhighlight>
395

edits

Navigation menu