RZVector3 RZSpline::GetPointBySegmentFactor (tINT SegKnot,tF32 Factor)
{
tINT p0=SegKnot-1;
tINT p1=SegKnot;
tINT p2=SegKnot+1;
tINT p3=SegKnot+2;
if (p0<0) p0=0;
if (p1<0) p1=0;
if (p2<0) p2=0;
if (p3<0) p3=0;
if (p0>=NumKnots) p0=NumKnots-1;
if (p1>=NumKnots) p1=NumKnots-1;
if (p2>=NumKnots) p2=NumKnots-1;
if (p3>=NumKnots) p3=NumKnots-1;
tF32 t1=Factor;
tF32 t2=t1*t1;
tF32 t3=t2*t1;
RZVector3 Pos=((Knots[p1].Pos*2)+(-Knots[p0].Pos+Knots[p2].Pos)*t1+(Knots[p0].Pos*2-Knots[p1].Pos*5+Knots[p2].Pos*4-Knots[p3].Pos)*t2+(-Knots[p0].Pos+Knots[p1].Pos*3-Knots[p2].Pos*3+Knots[p3].Pos)*t3)*0.5F;
return Pos;
}
Catmull Rom Tension?
Any ideas how I can implement some sort of "Tension" parameter in my evaluator?
I'm getting positions via subdivision. My "GetPoint" routine first works out what segment I'm interested in and how long it is and gets a factor of 0-1 along that particular segment, then calls this code to get the position:
I want to add some sort of tension parameter to all this to affect the straightness of the lines further from the control points iyswim. I don't have an exact spec in mind, so anything that helps bunch the curviness toward the control points based on a 0-1 value will do me. I've messed around a bit but have come up with nothing that works nicely.
Any suggestions gratefully recieved, thanks.
How did you derive your formula ? From the degree of t I can only guess it's something like a Cubic Hermite spline.
If so, the above link actually shows how to calculate with a tension parameter (Cardinal spline). But I can't say if your calculating your tangents right.
If so, the above link actually shows how to calculate with a tension parameter (Cardinal spline). But I can't say if your calculating your tangents right.
Catmull Rom splines with Tension are called Cardinal Splines. They scale the tangents to produce tension.
Add Bias and they are called Biased Cardinal Splines.
Throw in Continuity and you have TCB splines (or Kochanek Bartels splines). They are compatible with Catmull Rom such that the defaults of TCB=0 produce the exact same curve. Then you have localized (per control point) control over all 3.
Add Bias and they are called Biased Cardinal Splines.
Throw in Continuity and you have TCB splines (or Kochanek Bartels splines). They are compatible with Catmull Rom such that the defaults of TCB=0 produce the exact same curve. Then you have localized (per control point) control over all 3.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement