C# 中的 Atan2(或类似语言) [英] Atan2 in C# (or similar lanaguge)

查看:43
本文介绍了C# 中的 Atan2(或类似语言)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我指出一个用 C# 定义的 Atan2 的好例子(或隐约接近 C# 的东西),它不使用任何内部数学方法?这是在 .NET Microframework 上的,因此没有内部数学库之类的东西.我已经定义了 Sin()/Cos(),但是我在使用 Atain2 时遇到了很多麻烦.

Can anyone point me to a good example of Atan2 defined in C# (or something vaguely close to C#) that doesn't use any internal math methods? This is on .NET Microframework, so there is no such thing as an internal math library. I have already defined Sin()/Cos(), but I am having a lot of trouble with Atain2.

NETMF 中有一些散点图数学库,但我发现它们都有缺陷或损坏.其中一个主要的甚至没有正确定义 PI!

There are a few scatter shot math libraries in NETMF, but I have found them all to be flawed or broken. One of the major ones didn't even define PI correctly!

推荐答案

Wikipedia/atan2 然后使用 维基百科上 arctan 的无限级数展开.

只需总结系列中的术语,直到最后一个术语足够小以适合您的应用程序.
误差小于最后一项,因为它是严格的递减函数.

Just sum up terms in the series until the last term is small enough for your application.
The error is less then the last term since it is an strictly decreasing function.


由于您使用的是 .NET Micro 框架,因此您的计算资源可能不足.根据您所需的精度,您可能会考虑预先计算 cos、sin、atan2 等值的表,并且只需使用最接近的值的简单查找.另一方面,如果您需要太高的精度,这会浪费一些内存.


Since you´re on the .NET Micro framework you might be low on computational resources. Depending on your required precision you might consider precalculating a table of the cos, sin, atan2, etc values and just use a simple lookup of the closest value. On the other hand this wastes some memory if you need too high precision.

这篇关于C# 中的 Atan2(或类似语言)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆