资源简介
atan2的查表法实现,支持宏定义调整精度,非常适合没有带FPU的MCU使用。

代码片段和文件信息
// ConsoleApplication4.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef float float32_t;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include “atan2_tab.h“
int main()
{
atan2_tab_init();
double res_lib;
double res_tab;
#define LUT_NUM 4096
#define PRICISION 0.001
for (int i = 0; i < LUT_NUM; i++)
{
//第一象限
res_lib = atan2(i (LUT_NUM - 1));
res_tab = atan2_tab_calc(i (LUT_NUM - 1));
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“第一象限x=%d y=%d\n diff:%.5f“ (LUT_NUM - 1) i fabs(res_lib - res_tab));
}
res_lib = atan2((LUT_NUM - 1) i);
res_tab = atan2_tab_calc((LUT_NUM - 1) i);
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“第一象限x=%d y=%d diff:%.5f\n“ i (LUT_NUM - 1) fabs(res_lib - res_tab));
}
//第二象限
res_lib = atan2(i -(LUT_NUM - 1));
res_tab = atan2_tab_calc(i -(LUT_NUM - 1));
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“第二象限x=%d y=%d diff:%.5f\n“ -(LUT_NUM - 1) i fabs(res_lib - res_tab));
}
res_lib = atan2((LUT_NUM - 1) -i);
res_tab = atan2_tab_calc((LUT_NUM - 1) -i);
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“第二象限x=%d y=%d diff:%.5f\n“ -i (LUT_NUM - 1) fabs(res_lib - res_tab));
}
//第三象限
res_lib = atan2(-i -(LUT_NUM - 1));
res_tab = atan2_tab_calc(-i -(LUT_NUM - 1));
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“第三象限x=%d y=%d diff:%.5f\n“ -(LUT_NUM - 1) -i fabs(res_lib - res_tab));
}
res_lib = atan2(-(LUT_NUM - 1) -i);
res_tab = atan2_tab_calc(-(LUT_NUM - 1) -i);
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“第三象限x=%d y=%d diff:%.5f\n“ -i -(LUT_NUM - 1) fabs(res_lib - res_tab));
}
//第四象限
res_lib = atan2(-i (LUT_NUM - 1));
res_tab = atan2_tab_calc(-i (LUT_NUM - 1));
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“1第四象限x=%d y=%ddiff:%.5f\n“ (LUT_NUM - 1) -i fabs(res_lib - res_tab));
}
res_lib = atan2(-(LUT_NUM - 1) i);
res_tab = atan2_tab_calc(-(LUT_NUM - 1) i);
if (fabs(res_lib - res_tab) > PRICISION)
{
printf(“2第四象限x=%d y=%d diff:%.5f\n“ -i (LUT_NUM - 1) fabs(res_lib - res_tab));
res_lib = atan2(-(LUT_NUM - 1) i);
res_tab = atan2_tab_calc(-(LUT_NUM - 1) i);
}
res_lib = atan2((LUT_NUM - 1) -4094);
res_tab = atan2_tab_calc((LUT_NUM - 1) -4094);;
res_lib = atan2(-(LUT_NUM - 1) 208);
res_tab = atan2_tab_calc(-(LUT_NUM - 1) 208);
}
system(“pause“);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2866 2018-10-13 18:45 atan2_lut_test.cpp
文件 2404 2018-10-13 18:39 atan2_tab.cpp
文件 822 2018-10-13 18:39 atan2_tab.h
- 上一篇:室内定位技术论文
- 下一篇:ecshop分类按拼音索引
相关资源
- SVR算法程序可运行
- 计算机图形学 边填充算法实现代码
- 福建师范大学历年算法考卷
- 栈的实现及应用,六种基本算法
- Bresenham算法绘制线段并利用“橡皮筋
- 介绍几种压缩算法及《笨笨数据压缩
- 改进的BP神经网络算法
- A星算法_原理讲解_例子
- 云模型的相关算法cloud
- 旋转矩阵求欧拉角的简单算法
- 栅栏填充算法源码(VC)
- RSA算法源码
- 关联分析Apriori算法实现
- [免费]relax算法成像
- 操作系统 LRU算法 实验报告 及 程序代
- 分治法快速排序算法QuickSort C
- 现代谱估计算法 music ESPRIT 谐波分解
- MUSIC算法c 实现
- 007出纳管理系统 v7[1].5.94 算法注册机
- 克鲁斯卡尔算法C和C 实现代码
- capon波束形成算法-VC实现
- QGA 量子遗传算法
- 利用OpenGL写毛笔字算法
- 带头结点的单链表的c算法实现
- 自适应隐写算法wow
- 协同过滤算法源码
- RSA AES DES ECC加密算法源码
- 密码学课程设计:DES加密解密算法的
- 北航人工智能原理课大作业源代码,
- A*算法的2D演示(带源码)
评论
共有 条评论