Hi,
you can use standard CodeWarrior library functions. however they are relatively (depends on application) slow:
#include <math.h>
double atan(double x);
float atanf(float x);
long double atanl(long double x);
Another possibility is to use math and control library which uses fractional arithmetics and polynomial substitution of the functions:
Search for mc9s12zvm_ammclib at nxp.com to get more info or
to download. (you must press "more" to find library in collapsed list)
Best regards,
Ladislav
The last possibility is to use own searching table...depends on required precisiion.
Hi,
you can use standard CodeWarrior library functions. however they are relatively (depends on application) slow:
#include <math.h>
double atan(double x);
float atanf(float x);
long double atanl(long double x);
Another possibility is to use math and control library which uses fractional arithmetics and polynomial substitution of the functions:
Search for mc9s12zvm_ammclib at nxp.com to get more info or
to download. (you must press "more" to find library in collapsed list)
Best regards,
Ladislav
The last possibility is to use own searching table...depends on required precisiion.
Share my code "Clockwise Rotation"
from (A, B) to (X,Y)
#include "math.h"
double atan(double);
float atanf(float);
int16_t iA, iB, iX, iY;
float fAngle, fDistance, fRotate;
fAngle = atan2f (iB, iA);
fDistance = sqrt(pow(iA,2) + pow(iB,2));
iX = fDistance * cos(fAngle - fRotate);
iY = fDistance * sin(fAngle - fRotate);
Best Regards,
Aaron
Reference:
Hi Ladislav,
Very useful. Thank you.
Best Regards,
Aaron