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

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

// ex_tand.nxc
// Display values generated by the tand API call.
// This program runs indefinitely -- press gray button to exit.
// Reguires enhanced firmware 1.28 or later.
#define DELTA 22.5
// Angles from -67.5 degrees to almost 90.0 degres stepped by 22.5 degrees.
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("%5.1f", angle));
TextOut(40, screen_y, FormatNum("%8.4f", tand(angle)));
}
while (true);
}