在C#(或类似lanaguge)ATAN2 [英] Atan2 in C# (or similar lanaguge)

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

问题描述

任何人都可以点我ATAN2在C#(或东西隐约接近C#)定义,不使用任何内部的数学方法,一个很好的例子?这是在.NET Microframework,所以作为内部数学库没有这样的事情。我已经定义仙()/ 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!

推荐答案

这是实施应该是相当直截了当上的维基/ ATAN2 ,然后使用无穷级数在维基百科上反正切的。

An implementation should be quite straight forward starting with the definition on Wikipedia/atan2 and then using the infinite series expansion of arctan on Wikipedia.

刚总结方面的系列,直到最后一项是为你的应用足够小。结果
中的误差小于上一届因为它是一个严格递减函数

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.

编辑:结果
自you're在.NET Micro Framework的你可能会在较低的计算资源。根据您的要求的精确度可以考虑预先计算的COS,罪恶,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#(或类似lanaguge)ATAN2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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