-
Notifications
You must be signed in to change notification settings - Fork 7
cos
gicking edited this page Feb 10, 2018
·
4 revisions
back to Command Reference / Math
Calculates the cosine of an angle (in radians). The result will be between -1 and 1.
Note: for conversion degrees to radians, use rad2deg()
- defined in
misc.h
- auto-loaded in
main_general.h
- no
#define
required
y = cos(a)
-
input:
- a: The angle in Radians (float)
-
output:
- none
- The cosine of the angle (float).
The below code prints a table for y=cos(x) between 0..360 degrees. Note that the example requires option #define USE_FTOA
in file config.h
for floating point output.
#include "main_general.h"
#include "uart1.h"
#include "putchar.h"
void setup() {
float x,y;
char s1[20], s2[20];
// init UART and printf()
UART1_begin(115200);
putcharAttach(UART1_write);
// allow the terminal to launch
sw_delay(1000);
// print math table
for (x=0.0; x<=360.0; x+=0.5) {
y = cos(deg2rad(x));
printf("%s %s\n", floatToString(s1,x,2), floatToString(s2,y,2));
}
}
void loop() {
// dummy
}
- tbd
-
Getting Started
-
- General Commands
- Libraries
- LCD BTHQ21605V
- poti AD5280
- poti AD5282
- freemodbus
- PetitFS SD-card (min)
- FatFS: SD card (full)
- Board Specific
-
- Universal
- Board Specific