NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
ex_tan.nxc

This is an example of how to use the tan function.

// ex_tan.nxc
// Display values generated by the tan API call.
// This program runs indefinitely -- press gray button to exit.
// Reguires enhanced firmware 1.28 or later.
#define DELTA PI / 8
// Angles from -3/8 PI radians to almost P1/2 radians stepped by PI/8 radians.
const float data[] =
{
-3 * DELTA,
-2 * DELTA,
-DELTA,
0.0,
DELTA,
2 * DELTA,
3 * DELTA,
4 * DELTA - 0.01
};
// Display a table of angles and their tangents. The angles are the ones
// specified above.
task main()
{
const int items = ArrayLen(data);
for (int i = 0; i < items; ++i)
{
int screen_y = 56 - 8 * i;
float angle = data[i];
TextOut(0, screen_y, FormatNum("%7.4f", angle));
TextOut(45, screen_y, FormatNum("%8.4f", tan(angle)));
}
while (true);
}