| 12-31-2008, 03:53 AM | #1 |
Hey everyone, I've been trying to convert TCB notations (tension continuity and bias) into Hermite curves. Here's my source on how to do it for 3 space points, quite good for positions, but when it comes to quaternions, it doesn't really work that way. Currently I'm using this formula in Maxscript: Code:
fn InTan p1 p2 p3 t c b = ( local q1 = p2 - p1 local q2 = p3 - p2 q1 = q1*0.5*(1.0-t)*(1.0-c)*(1.0+b) q2 = q2*0.5*(1.0-t)*(1.0+c)*(1.0-b) return q1 + q2 ) fn OutTan p1 p2 p3 t c b = ( local q1 = p2 - p1 local q2 = p3 - p2 q1 = q1*0.5*(1.0-t)*(1.0+c)*(1.0+b) q2 = q2*0.5*(1.0-t)*(1.0-c)*(1.0-b) return q1 + q2 ) It may be a bit hard to understand. P1, p2, and p3 are the quaternions, while tcb are the respective values to tension continuity and bias. Here's my source for the conversion: http://www.cubic.org/docs/hermite.htm For a 3D normal point the function works perfectly, but when it comes with quaternions, it messes up. I also looked at Dex's scripting and I found how they "try" to calculate TCB: Code:
fn qcompA prev_quat now_quat next_quat=
(
return now_quat * exp(-(1/4)*(logN((inverse now_quat)*next_quat)+ logN((inverse now_quat)*prev_quat)))
)
Intan = qcompA q1 q2 q2The function works well, but it's not as accurate as Art Tools and only returns InTan and OutTan when the tension = 1.0, continuity = 1.0 and bias = 1.0. The tcb values does not affect that function. |
