有关 (1) / ( b ^ c ) 形式的函数的数学问题
我发现遵循 1 / bc 模式的函数会产生漂亮的曲线,可以很好地与插值函数结合。
我使用该函数的方式是将“c”视为变化值,即 0 和 1 之间的插值,同时改变 b 以获得“清晰度”。我用它来计算 0 和 1 之间的插值,所以一般来说,我使用的函数是这样的:
float interpolationvalue = 1 - 1/pow(100,c);
linearinterpolate( val1, val2, interpolationvalue);
到目前为止,我一直在使用一种黑客方法来使其“工作”,因为当插值值 = 1 时,该值非常接近但不完全是 0。
所以我想知道是否有一个 或 形式的函数可以重现与 1 / bc 产生的曲线相似的曲线,其中 c = 0结果 = 1 且 c = 1 结果 = 0。
甚至 C = 0、结果 = 0 且 C = 1 结果 = 1。
感谢您的帮助!
I've found functions which follow the pattern of 1 / bc produce nice curves which can be coupled with interpolation functions really nicely.
The way I use the function is by treating 'c' as the changing value, i.e. the interpolation value between 0 and 1, while varying b for 'sharpness'. I use it to work out an interpolation value between 0 and 1, so generelly the function I use is as such:
float interpolationvalue = 1 - 1/pow(100,c);
linearinterpolate( val1, val2, interpolationvalue);
Up to this point I've been using a hacked approach to make it 'work' since when interpolation value = 1 the value is very close to but not quite 0.
So I was wondering, is there a function in the form of or one which can reproduce similar curves to the ones produced by 1 / bc where at c = 0 result = 1 and c = 1 result = 0.
Or even C = 0, result = 0 and C = 1 result = 1.
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于插值,提供最大灵活性的方法是使用 样条线,在您的情况下,二次样条线似乎就足够了。维基百科页面包含大量数学内容,但您可以在谷歌上找到改编的描述。
For interpolation the approach offering the most flexibility is using splines, in your case quadratic splines would seem sufficient. The wikipedia page is math heavy, but you can find adapted desciptions on google.
1 - c ^ b
的b
值较小?另一种选择是使用三次多项式并指定 0 和 1 处的斜率。1 - c ^ b
with small values forb
? Another option would be to use a cubic polynomial and specifying the slope at 0 and 1.您可以使用
A - 1 / b^(c + a)
形式的类似曲线,选择A
和a
的值来匹配你的限制。因此,对于c = 0, result = 1
:和对于
c = 1, result = 0
:组合这些,我们可以在以下位置找到
a
b
的条款:所以:
You could use a similar curve of the form
A - 1 / b^(c + a)
, choosing values ofA
anda
to match your constraints. So, forc = 0, result = 1
:and for
c = 1, result = 0
:Combining these, we can find
a
in terms ofb
:So:
在数学家使用的实数中,您指定的形式的函数不会返回 0,除法不能做到这一点。 (1/x)==0 没有实数解。在浮点算术中,计算机使用的实际算术关系很差,您可以编写 1/(MAX_FP_VALUE^1) ,这将为您提供尽可能接近 0 的值(实际上,它可能会给您一个 NaN 或IEEE 754 允许的其他奇数返回之一)。
而且,我相信您已经注意到,1/(b^0) 始终返回 1,因为根据 0 次方的定义,b^0 始终为 1。
因此,c = 0 的函数不会产生结果为 0。
对于 c = 1,结果 = 1,设置 b = 1
但我想这只是部分答案,我不太确定我理解你想要做什么。
问候
马克
In real numbers, the ones that mathematician use, no function of the form you specify is ever going to return 0, division can't do that. (1/x)==0 has no real solutions. In floating point arithmetic, the poor relation of real arithmetic that computers use, you could write 1/(MAX_FP_VALUE^1) which will give you as close to 0 as you are ever going to get (actually, it might give you a NaN or one of the other odd returns that IEEE 754 allows).
And, as I'm sure you've noticed, 1/(b^0) always returns 1 since b^0 is, by definition of 0-th power, always 1.
So, no function with c = 0 will produce a result of 0.
For c = 1, result = 1, set b = 1
But I guess this is only a partial answer, I'm not terribly sure I understand what you are trying to do.
Regards
Mark