Jump to content
  • Advertisement
Sign in to follow this  
cbuenov

Cubic Bezier Motion Path

This topic is 3316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In 3DMax I would like to get the equation of the path of an animated object, which I believe to be a cubic bezier. Through this software's scripting language (MaxScript) I can get the cubic bezier equation of the object's position versus time (X(t),Y(t),Z(t)) (from the Curve Editor), using in_tangents, out_tangents, etc., and consequently determining the 4 points that define a cubic bezier (vertices and handles). How can I compose the motion path equation from the X(t), Y(t) and Z(t) cubic bezier equations? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Do you mean you want the equivalent function f(x) that represents the bezier curve? Sadly, bezier curves are not represented by functions. So, for example, getting the length of the curve is not as easy as integrating f(b) - f(a). There may be alternative methods to achieve what you wanted to use the function for though.

Share this post


Link to post
Share on other sites
Quote:
Original post by bigneilm3
Do you mean you want the equivalent function f(x) that represents the bezier curve? Sadly, bezier curves are not represented by functions. So, for example, getting the length of the curve is not as easy as integrating f(b) - f(a). There may be alternative methods to achieve what you wanted to use the function for though.


Share this post


Link to post
Share on other sites
3DMax draws cubic bezier splines. If I can get the control points of the cubic bezier that defines the motion path (Z(x)) then I will be able to plot it, which is what I want to do.

But all I have are the X(t) and Z(t) cubic bezier equations.
x(t) = At^3 plus Bt^2 plus Ct plus D, for instance.

I have differentiated these equations (dx/dt, dz/dt) in order to get the tangents at t=0 and t=1, but I'm still missing something as the results do not match perfectly the real path.

Share this post


Link to post
Share on other sites
It really doesn't make sense to try and find equations like Z(x), Y(x), since the path might not be representable as single-valued functions...I'm thinking of the case where the spatial path is a loop, or is self-intersecting in space (even if just when projected onto some cardinal plane that you pick such as the xy plane). If you just want to draw the path, why not simply evaluate X(t), Y(t), Z(t) at different points in time, e.g., in 0.1 second increments, something like:

point 0 = (X(0.0), Y(0.0), Z(0.0))
point 1 = (X(0.1), Y(0.1), Z(0.1))
point 2 = (X(0.2), Y(0.2), Z(0.2))
point 3 = (X(0.3), Y(0.3), Z(0.3))
point 4 = (X(0.4), Y(0.4), Z(0.4))
...
point N = (X(max_time), Y(max_time), Z(max_time))

Share this post


Link to post
Share on other sites
Quote:
Original post by grhodes_at_work
It really doesn't make sense to try and find equations like Z(x), Y(x), since the path might not be representable as single-valued functions...I'm thinking of the case where the spatial path is a loop, or is self-intersecting in space (even if just when projected onto some cardinal plane that you pick such as the xy plane). If you just want to draw the path, why not simply evaluate X(t), Y(t), Z(t) at different points in time, e.g., in 0.1 second increments, something like:

point 0 = (X(0.0), Y(0.0), Z(0.0))
point 1 = (X(0.1), Y(0.1), Z(0.1))
point 2 = (X(0.2), Y(0.2), Z(0.2))
point 3 = (X(0.3), Y(0.3), Z(0.3))
point 4 = (X(0.4), Y(0.4), Z(0.4))
...
point N = (X(max_time), Y(max_time), Z(max_time))



Mr. Rhodes,
I guess my original description of the problem wasn't quite right. I could, of course, evaluate X(t), Y(t), Z(t) at different points in time, but I don't want a lot of points drawn on the screen. Also, a whole path might not be represented by single-valued functions as you have stated, but it is possible to draw it segment by segment, using cubic Beziers.

As far as I know, that's what 3DMax does: it draws splines made up of cubic bezier segments. All I need is the coordinates of two control points for each curve that makes up the path.

And that's where I'm missing something. I have the cubic bezier equations of X(t), Y(t), Z(t) and their respective control points but I haven't been able to properly "translate" them into the control points of a 3D path.



Share this post


Link to post
Share on other sites
Maxscript is just giving you the cubic equation, e.g, the coefficients? I think you can solve directly for the control points by looking at the closed form equations for the coefficients. This math has been done by many, many people so you don't have to do it...In the form you wrote earlier, if the control net is given by points p0, p1, p2, and p3, with p0 and p3 being your endpoints and p1 and p2 being the intermediate tangent control points that you want, the C and B coefficients for a cubic bezier segment are given by:

C = 3 * (p1 - p0)
B = 3 * (p2 - p1) - C

You have C and B from maxscript, and p0. Solve the first equation for p1. Then you have B, so plug the value of p1 into the second equation and solve for p2. You already have point p3, so after solving those two you will have all 4 points.

Share this post


Link to post
Share on other sites
Quote:
Original post by grhodes_at_work
Maxscript is just giving you the cubic equation, e.g, the coefficients? I think you can solve directly for the control points by looking at the closed form equations for the coefficients. This math has been done by many, many people so you don't have to do it...In the form you wrote earlier, if the control net is given by points p0, p1, p2, and p3, with p0 and p3 being your endpoints and p1 and p2 being the intermediate tangent control points that you want, the C and B coefficients for a cubic bezier segment are given by:

C = 3 * (p1 - p0)
B = 3 * (p2 - p1) - C

You have C and B from maxscript, and p0. Solve the first equation for p1. Then you have B, so plug the value of p1 into the second equation and solve for p2. You already have point p3, so after solving those two you will have all 4 points.


Mr. Rhodes,

Maxscript doesn't give the coefficients (A,B,C,D), and I don't think I need them since 3DMax has a function that takes in the 4 control points of a bezier curve and draws it. Through Maxscript I can get the endpoints and control points for the X(t), Y(t) and Z(t) curves.

I've got:
p0 and p3 (which are the same for all curves)

Curve X(t): p1x, p2x
Curve Y(t): p1y, p2y
Curve Z(t): p1z, p2z

So, I have the endpoints and control points FOR THE COMPONENT CURVES of the 3D motion path.

In order to draw this path in space I just need points p1 and p2 of THIS curve. They must be a composite of p1x, p1y, p1z and p2x, p2y, p2z, but I'm missing something (and I bet it is something stupid!).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!