Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: Help with ColladaMaya bezier animation

  1. #11
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Quote Originally Posted by sthomas
    I'm not sure about your reasoning there.
    There was no reasoning But there was a warning that I like maths

    Let P0 be 2-dimensional point [P0.x; P0.y]

    Consider Bezier curve with control points P0, P1, P2 and P3:
    x(t) = P0.x*(1-t)^3 + 3*P1.x*t(1-t)^2 + 3*P2.x*t^2(1-t) + P3.x*t^3
    y(t) = P0.y*(1-t)^3 + 3*P1.y*t(1-t)^2 + 3*P2.y*t^2(1-t) + P3.y*t^3
    where 0 <= t <= 1

    Add the constraint imposed by the tangential definition: the points P0, P1, P2 and P3 are equally spaced in x direction:
    P0.x = a P1.x = a + b P2.x = a + 2b P3.x = a + 3b

    Put into equation for x(t):
    x(t) = a*(1-t)^3 + 3*(a + b)*t(1-t)^2 + 3*(a + 2b)*t^2(1-t) + (a + 3b)*t^3
    = a { (1-t)^3 + 3*t(1-t)^2 + 3*t^2(1-t) + t^3 } + b { 3t(1-t)^2 + 6*t^2(1-t) + 3*t^3 }
    = a { ((1-t)+t)^3 } + b { 3t (1 - 2t + t^2) + 6(t^2 - t^3) + 3*t^3 }
    = a { 1^3 } + b { 3t - 6t^2 + 3t^3 + 6t^2 - 6t^3 + 3*t^3 }
    = a + b { 3t }
    = 3t*b + a
    Therefore,
    x = 3t*b + a
    x - a = 3t*b
    t = (x - a)/(3b)
    Now we can substitute 't' into y(t) = P0.y*(1-t)^3 + 3*P1.y*t(1-t)^2 + 3*P2.y*t^2(1-t) + P3.y*t^3
    That would be a lot of algebra, but since t is linearly dependent on x will can see that y will be cubic in terms of x.
    Hence the tangential form can only express curves in form y = f(x).

  2. #12
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Add the constraint imposed by the tangential definition: the points P0, P1, P2 and P3 are equally spaced in x direction:
    Where does this constraint come from?

  3. #13
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Quote Originally Posted by sthomas
    One thing to keep in mind is that the point-tangent form is also a parametric curve. The tangents being discussed are parametric tangent vectors (dx/dt, dy/dt), not a dy/dx tangent.
    EDIT: Yep, this would work.

    However, from the description it seems to me that the tangents are in scalar form dy/dx - more specificaly scalar (dy/dx)*(time interval)
    This information is not sufficiant to produce all posible control points

    Quote Originally Posted by sthomas
    Where does this constraint come from?
    There is only one value stored per tangent - I assume it defines the y coordinate of the control point. The x coordinate is not stored so I assume it is implicitly defined as one thrid of the time interval between keys. I got this from this post: https://collada.org/public_forum/viewtopic.php?t=277

    I am using following equation to get the control points:

    CP(0) = (input[N], output[N])
    CP(1) = ((input[N] * 2 + input[N+1]) / 3, output[N] + out_tangent[N] / 3)
    CP(2) = ((input[N] + input[N+1] * 2) / 3, output[N+1] - in_tangent[N+1] / 3)
    CP(3) = (input[N+1], output[N+1])


    PS: Going to bed

  4. #14
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    There is only one value stored per tangent
    That's not right. If your control points are 1-dimensional then sure, a 1-dimensional tangent is fine. But for 3d control points the tangents should be 3d also. Otherwise the tangents don't give you enough information. So if you thought that each tangent is just a single scalar value, then yes I can see why the point-tangent form doesn't seem to work out, but I'm sure you're mistaken about the tangents.
    I am using following equation to get the control points:

    CP(0) = (input[N], output[N])
    CP(1) = ((input[N] * 2 + input[N+1]) / 3, output[N] + out_tangent[N] / 3)
    CP(2) = ((input[N] + input[N+1] * 2) / 3, output[N+1] - in_tangent[N+1] / 3)
    CP(3) = (input[N+1], output[N+1])
    The confusing thing about these equations is that it makes it look like the t-values (described with the "input" array) are a component of the resulting control point. They're not, and I think that's what was throwing you off. A better way of writing the above equations would be

    CP0 = output[N]
    CP1 = output[N] + out_tangent[N] / 3
    CP2 = output[N+1] - in_tangent[N+1] / 3
    CP3 = output[N+1]

    The t-values / inputs are used for interpolating between these control points, but they're not part of the control points. If you look at these equations you'll see they look remarkably similar to what I originally posted in the thread:
    Quote Originally Posted by sthomas
    p1 = V1
    p2 = p1 + 1/3 T1
    p3 = p4 - 1/3 T2
    p4 = V4
    They mean the same thing.

  5. #15
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    I am using following equation to get the control points:

    CP(0) = (input[N], output[N])
    CP(1) = ((input[N] * 2 + input[N+1]) / 3, output[N] + out_tangent[N] / 3)
    CP(2) = ((input[N] + input[N+1] * 2) / 3, output[N+1] - in_tangent[N+1] / 3)
    CP(3) = (input[N+1], output[N+1])
    By the way I see that these equations also appear in the book (page 125), except that they're missing the /3 on the tangents. This is basically a description of how to convert the control point-tangent form of the Bezier curve to the 4-control point form, but it's not obvious that that's what it is in the book. This description should probably either be removed or rewritten to be more clear, and the /3 math error fixed of course.

  6. #16
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Yes, you are right, the problem is that I think that each tangent is single scalar value.

    First, the topic of this post is “Help with ColladaMaya bezier animation” so we are talking about the <animation> element. Right?

    Second, animations in Blender are done using four control points which are moved on a plane. This implies that the control points or tangents for animations need to be two dimensional. Right?

    Third, here is a snippet from Seymour.dae from Sample Data from Collada DOM:
    <animation id="l_hip_rotateY">
    <float_array id="...-input">0 0.416667 0.833333 </float_array>
    <float_array id="...-output">0 -5.89913 0 </float_array>
    <float_array id="...-intangents">-5.89912 0 2.45797 </float_array>
    <float_array id="...-outtangents">-2.45797 0 5.89912 </float_array>
    <Name_array id="...-interpolations">BEZIER BEZIER BEZIER </Name_array>
    </animation>
    It seems to me that there is only one tangent stored per keyframe. How do I get four two dimensional control points from these data?

  7. #17
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Second, animations in Blender are done using four control points which are moved on a plane. This implies that the control points or tangents for animations need to be two dimensional. Right?
    When I say that the curve is n-dimensional, I'm not counting the independent variable t as one of the dimensions. I'm guessing what Blender does is provide independent graphs of x vs. t, y vs. t, and z vs. t. t is the independent variable and x, y, and z can all be expressed as functions of t (with all the limitations that come with the term "function"). The resulting curve is p(t) = [x(t), y(t), z(t)].

    If all you're animating is x, then a single scalar value is all you need to provide the tangent, since x = f(t) is a scalar function that you can compute the derivative of to get a scalar back. Note that just because x is graphed against t does not mean that you can describe any planar curve with x = f(t).

    If instead your curve is [x(t), y(t)], then the tangent vector would be [x'(t), y'(t)]... it's also a 2d vector.

    It seems to me that there is only one tangent stored per keyframe. How do I get four two dimensional control points from these data?
    The given control points are 1-dimensional (they're angles), so you want four 1d control points, not four 2d control points. The keyframes form two of the control points, and the tangents can be used to compute two additional control points for Bezier interpolation using the formulas I gave above.

    Ok I think I'm going to give up at this point. For more info behind the math you can google "vector functions". Good luck.

  8. #18
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Sorry, I hate when I do not understand something... it is my nature

    Maybe an example will do. Here are four curves created in Blender. (Hence valid curves by definition)


    Could you please tell me the values of the four scalar tangents? (Since the curves are different, I assume the tangents will be different) In other words, how do I save these curves in Collada?

  9. #19
    Junior Member
    Join Date
    Sep 2006
    Posts
    14
    Please do not give up. At least answer the last post - all I want is four numbers, nothing else.

  10. #20
    Senior Member
    Join Date
    Jan 2006
    Location
    Foster City, CA
    Posts
    540
    Those look like generic 2d Bezier curves, e.g. x on the horizontal axis, y on the vertical axis, both parameterized with respect to an independent variable t. The tangents will be 2d and can be computed as 3(p2-p1) and 3(p4-p3), as was discussed before, where p1, p2, p3, and p4 are the middle control points.

    If that's meant to be a graph of x vs. t, then it's wrong to allow the tangents to be moved in 2-dimensions. To see why consider what would happen if you pulled p2 to the left of p1, which is conceptually perfectly reasonable, even if Blender's interface prevents you from doing it. If you did that then one t value would have multiple x values, so x could no longer be expressed as a function of t, which means that t would no longer be an independent variable and you'd need to reparameterize.

Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •