PDA

View Full Version : optimized spline curvature


DeFi
03-20-2008, 10:56 AM
Hello,
I'm trying to animate a character with a tail using spline IK. The tails curves need to be as smooth as possible but easy to animate, so I took a spline with not too many control points. Unluckily, if set to smooth, the splines curvature is not as smooth as i want it to be. Setting the points to bezier enables me to optimize the curvature, but the the spline can not be animated without looking totally wrong in other positions. So I tried to use a NURBS point curve instead. It had a nearly perfect curvature.

http://www.defi1.de/splineIK/curves.jpg
red = spline with smooth points
yellow = NURBS point curve

The problem with the NURBS curve was, that it made the whole bone chain wobble when moving single control points, thus making animation of the curve impossible.

Is there a way to obtain an automatically smoothed curve that at least mimics globally minimizing the curvature like NURBS does and doesn't mess up when animating the curve points? I'm posting this in the scripting forum, because some people here (like eek) know the math behind NURBS, b-splines and bezier curves and I have a feeling that this problem can only be solved by scripting and math or even writing a plugin in c++.

Greetings

DeFi

eek
03-20-2008, 02:49 PM
Your'll have to write I think a b-spline method that uses conic sections. Conic sections are what allow nurbs curves to perfect arcs.

There a slice through conic cones, essentially how a 3d curve is projected into 4d space - for nurbs. I havent worked with curves in a while, so I'll have to look at the math again.

http://mathworld.wolfram.com/NURBSCurve.html

So this is the math, it builds a weighted b-spline using the summation of b-spline basis function * a weight. Then id divides this by the sum of the basis function. I needs to do this because it needs to be normalized.

Personally I'd use a deboor or midpoint method for the spline as it may be faster, getting deboor to represent conic section is hard though - and i spent a while looking into it.

davestewart
03-20-2008, 08:04 PM
Um, yeah - I was just about say that, but Charles beat me to it ;)

DeFi
03-20-2008, 08:17 PM
Thank's for your answer.
Conic sections can be constructed from 5 given points if I remember correctly. One curve section has 2 border control points for sure and maybe 2 additional control points of neighboring sections. Leaves one missing point to compute a cone section and 2 missing points for sections at the end of the curve. Hmmm, I'm probably messing up everything.

The first solution I thought of, was extending the build in way of auto-smoothing spline points. Apparently 3dsmax computes a point P in smooth mode just like in bezier mode, but by adding an invisible bezier tangent handle that is parallel to the connection line between the neighbor points (P-1) and (P+1). If now it is possible to hijack an event handler that is evaluated every frame for a scripted modifier is it possible to do the following?

1. set all points to smooth mode
2. set all points to bezier mode
3. adjust the bezier tangent handles of P to be perpendicular to a weighted average of the directions from P to (P-2), ...,(P+2)
4. scale the bezier tangent handles with a custom value depending on the distances between P and it's neighbor points.

This could improve the built in heuristic as it includes the neighbor segments to compute the bezier tangent handle.... maybe. ;)

CGTalk Moderation
03-20-2008, 08:17 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.