切线、条件
如何绕过函数 tan (x) 未定义的角度,即 x != Pi/2 + k * PI ?
我尝试使用条件:
(x != 0) && (2 * x / M_PI - (int)(2 * x / M_PI ) ) < epsilon,
但它代表一个条件
x != Pi/2 + k * PI / 2。
感谢您的帮助。
How to bypass the angles at which the function tan (x) is not defined, ie x != Pi/2 + k * PI ?
I tried to use the condition:
(x != 0) && (2 * x / M_PI - (int)(2 * x / M_PI ) ) < epsilon,
but it represents a condition
x != Pi/2 + k * PI / 2.
Thanx for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
相同的条件可用于确定 cos(x) 的哪些值为零。感谢这个美妙的事实,您可以简单地执行以下操作(伪代码):
编辑: As In silico 指出,这是三角恒等式的结果:
tan(x) = sin(x) / cos(x)
在这种形式中,您可以看到,由于除以零,所以在 cos(x) = 0 的任何地方都会出现未定义的值。
The same condition can be used to determine which values of cos(x) will be zero. Thanks to that wonderful fact, you can simply do the following (pseudocode):
Edit: As In silico points out, this is a result of the trigonometric identity:
tan(x) = sin(x) / cos(x)
In this form, you can see that the undefined values will appear wherever cos(x) = 0 because of the division by zero.
尝试一下
会发现检查导致 tan(x) 未定义的 x 值。
How about trying
Will find check for the values of x that cause tan(x) to be undefined.
不使用切线吗?它比使用(正弦,余弦)对性能更高,但通常您可以使用(正弦,余弦)对而不必担心不连续性。
你用切线做什么?
Don't use tangent? It can be more performant than using a (sine, cosine) pair, but usually you can use a (sine, cosine) pair without worrying about discontinuities.
What are you using tangent for?