<abs>
#
Note
The <abs>
element used inside the FlightGear <expression>
tag is distinct from the
<abs>
element used in JSBSim
for XML configuration files - although they are closely related and both perform the same
mathematical operation.
Overview#
The <abs>
element takes the absolute value of a <property>
child element. It is the same
principle as functions of the same name in many programming languages.
Tip
For more information about absolute values in mathematics, see the Wikipedia article on the subject.
Syntax#
- The
<abs>
element must be a child element of an<expression>
element, and the<abs>
element must have a
<property>
child element.
Example#
One use case for the <abs>
element is when a numerical value needs to be checked or used in a
calculation, but whether or not the value is positive or negative is irrelevant.
In this example, passing the /velocities/vertical-speed-fps
as a value to the <abs>
element
will return the vertical speed as a positive number, regardless of whether its value is positive
or negative.
<abs>
<property>/velocities/vertical-speed-fps</property>
</abs>