用于网格操作的高斯衰减格式
下面的这个回报被定义为高斯衰减。我没有看到 e 或 2 的幂,所以我不确定这与高斯衰减有何关系,或者我是否使用错误的衰减类型在网格上获得良好的平滑变形:
Mathf.Clamp01 (Mathf.Pow (360.0, -Mathf.Pow (distance / inRadius, 2.5) - 0.01))
其中 Mathf.Clamp01
返回 0 到 1 之间的值。
inRadius
是变形的大小,距离
由以下因素确定:
sqrMagnitude = (vertices[i] - position).sqrMagnitude; // Early out if too far away if (sqrMagnitude > sqrRadius) continue; distance = Mathf.Sqrt(sqrMagnitude);
顶点
> 是网格顶点列表,position
是网格操作/变形的点。
我的问题分为两个部分:
1)上述实际上是高斯衰减吗?它是指数的,但似乎没有关键的 e 或 2 的幂...(更新 - 我看到图形似乎如何以类似高斯的方式平滑减小。也许这个函数不是问题 2 的原因如下)
2)我的网格变形不够平滑 - 考虑到上述参数,您会推荐不同的高斯衰减吗?
This return below is defined as a gaussian falloff. I am not seeing e or powers of 2, so I am not sure how this is related to the Gaussian falloff, or if it is the wrong kind of fallout for me to use to get a nice smooth deformation on my mesh:
Mathf.Clamp01 (Mathf.Pow (360.0, -Mathf.Pow (distance / inRadius, 2.5) - 0.01))
where Mathf.Clamp01
returns a value between 0 and 1.
inRadius
is the size of the distortion and distance
is determined by:
sqrMagnitude = (vertices[i] - position).sqrMagnitude; // Early out if too far away if (sqrMagnitude > sqrRadius) continue; distance = Mathf.Sqrt(sqrMagnitude);
vertices
is a list of mesh vertices, and position
is the point of mesh manipulation/deformation.
My question is two parts:
1) Is the above actually a Gaussian falloff? It is expontential, but there does not seem to be the crucial e or power of 2... (Updated - I see how the graph seems to decrease smoothly in a Gaussian-like way. Perhaps this function is not the cause for problem 2 below)
2) My mesh is not deforming smoothly enough - given the above parameters, would you recommend a different Gaussian falloff?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道网格等,但让我们看看数学:
f=360^(-0.1- ((d/r)^2.5) ) 看起来与高斯函数足够相似,可以“脱落”。
我将把指数分开来表明一点:
f= 360^( -(d/r)^2.5)*360^(-0.1)=(0.5551)*360^( -(d/r)^2.5)
如果 d-->+inf 则 f-- >0
如果 d-->+0 则 f-->(0.5551)
360 的指数始终为负(假设“距离”和“inRadius”始终为正),并且几乎随距离呈三次方(2.5 次方)变大(更负),因此该函数“下降”并且执行速度相当快。
结论:该函数不是高斯函数,因为它在负输入时表现不佳,并且可能由于其他原因。它确实表现出了您正在寻找的“脱落”行为。
改变 r 将改变衰减的速度。当 d==r 时,f=(1/360)*0.5551。
该函数永远不会超过 0.5551 且低于零,因此代码中的“裁剪”毫无意义。
我没有看到任何关于常数 360 的任何具体原因 - 改变它会稍微改变斜率。
干杯!
Don't know about meshes etc. but lets see that math:
f=360^(-0.1- ((d/r)^2.5) ) looks similar enough to gausian function to make a "fall off".
i'll take the exponent apart to show a point:
f= 360^( -(d/r)^2.5)*360^(-0.1)=(0.5551)*360^( -(d/r)^2.5)
if d-->+inf then f-->0
if d-->+0 then f-->(0.5551)
the exponent of 360 is always negative (assuming 'distance' and 'inRadius' are always positive) and getting bigger (more negative) almost cubicly ( power of 2.5) with distance thus the function is "falling off" and doing it pretty fast.
Conclusion: the function is not Gausian because it behaves badly for negative input and probably for other reasons. It does exibits the "fall off" behavior you are looking for.
Changing r will change the speed of the fall-off. When d==r the f=(1/360)*0.5551.
The function will never go over 0.5551 and below zero so the "clipping" in the code is meaningless.
I don't see any see any specific reason for the constant 360 - changing it changes the slope a bit.
cheers!