沿BSPLINE插值
我有一个非常简单的bspline-是两个点,互相指向对方。实际上,只是一行。
我写了一个邻接循环以沿着样条获得位置,就像这样:
for (float aCount=0;aCount<mSpline.Max();aCount+=1.0f/18.0f)
{
Vector aPos=mSpline.Get(aCount);
PlotPoint(aPos,Color(1,0,1));
}
现在,由于我每次都在步行1/18,所以我希望每个点都与Checkers对齐(因为有18个检查员)。但是,它们倾向于摆动,中间点正好在Checker边界上,两侧的替代点倾向于稍微聚集到中心。
对于我正在做的事情,我需要它们在Checker Borders上(或至少非常非常接近)。
我认为聚类是由沿着样条沿线的一些光插值误差引起的。这是我相关的样条函数(假设vtype = vector):
vtype Get(float thePos)
{
float aPos=thePos-floorf(thePos);
int aIPos=(int)floorf(thePos);
BSplinePoint& aP1=mPoints[_clamp(0,aIPos,mPoints.Size()-1)];
BSplinePoint& aP2=mPoints[_clamp(0,aIPos+1,mPoints.Size()-1)];
vtype aResult;
vtype aAB, aBC, aCD, aABBC, aBCCD;
Lerp(aAB,aP1.mPos,aP1.mOut,aPos);
Lerp(aBC,aP1.mOut,aP2.mIn,aPos);
Lerp(aCD,aP2.mIn,aP2.mPos,aPos);
Lerp(aABBC,aAB,aBC,aPos);
Lerp(aBCCD,aBC,aCD,aPos);
Lerp(aResult,aABBC,aBCCD,aPos);
return aResult;
}
inline void Lerp(vtype& theResult, vtype a, vtype b, float thePos) {theResult=a+(b-a)*thePos;}
是否有一种方法可以按摩它以获得我所需的结果,还是只是去做这种样条插值的工件?还是样条控制点的位置有某个因素? (将它们靠近/进一步移动似乎并没有改善任何东西,我仍然得到中心偏见)
I have a very simple Bspline-- it's two points, in/out normals pointing at each other. In fact, just a line.
I wrote a little for-next loop to get positions along the spline, like so:
for (float aCount=0;aCount<mSpline.Max();aCount+=1.0f/18.0f)
{
Vector aPos=mSpline.Get(aCount);
PlotPoint(aPos,Color(1,0,1));
}
Which produces the following result:
Now, since I was stepping 1/18th of the way each time, I expected each dot to be aligned with the checkers (since there's 18 checkers). However, they tend to wobble, with the halfway point being exactly on the checker boundary, and the alternate spots on either side tending to gather towards the center a little bit.
For what I'm doing, I need them to be on the checker borders (or at least, very, very close).
I assume the clustering is caused by some light interpolation error along the spline. Here are my relevant spline functions (assume vtype = Vector):
vtype Get(float thePos)
{
float aPos=thePos-floorf(thePos);
int aIPos=(int)floorf(thePos);
BSplinePoint& aP1=mPoints[_clamp(0,aIPos,mPoints.Size()-1)];
BSplinePoint& aP2=mPoints[_clamp(0,aIPos+1,mPoints.Size()-1)];
vtype aResult;
vtype aAB, aBC, aCD, aABBC, aBCCD;
Lerp(aAB,aP1.mPos,aP1.mOut,aPos);
Lerp(aBC,aP1.mOut,aP2.mIn,aPos);
Lerp(aCD,aP2.mIn,aP2.mPos,aPos);
Lerp(aABBC,aAB,aBC,aPos);
Lerp(aBCCD,aBC,aCD,aPos);
Lerp(aResult,aABBC,aBCCD,aPos);
return aResult;
}
inline void Lerp(vtype& theResult, vtype a, vtype b, float thePos) {theResult=a+(b-a)*thePos;}
Is there a way to massage this to get my desired result, or is this just going to an artifact of this kind of spline interpolation? Or is there some factor of the location of the spline control points? (Moving them closer/further doesn't seem to improve anything, I still get a center-bias)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论