Bezier curves are incorrect

cglynos
New Member
New Member

Bezier curves are incorrect

cglynos
New Member
New Member

Hello,

 

I have implemented a structure of Bezier Curve that complies to the mathematical rules, using de_casteljau's algorithm. I have tested my implementation with other libraries and we agree on the results. However, when I create a bezier curve in maya, using the same control vertices, the curve is incorrect.

 

Example:

import maya.cmds as mc

mc.curve( d=3, p=[(-1,0,0), (-1,2,0), (0,1,0), (1,2,0), (1,0,0)] )
mc.nurbsCurveToBezier( )

 

To evaluate the curve, I created a locator and used a motion path constrain and set the U value to 0.5.

 

When this curve is evaluated for t=0.5, maya returns (0.0, 1.5, 0.0), whereas the correct answer is { 0 , 1.375 , 0 }.

61ca2fa8-744a-4162-a3d3-1928a7c644db.jpg

Am I creating a bezier curve in maya properly? If so, why am I seeing different results?

 

0 Likes
Reply
Accepted solutions (1)
98 Views
4 Replies
Replies (4)

brentmc
Autodesk
Autodesk

Hi,

The result looks correct to me for the control points you have specified.

In the image below I have drawn some lines to show the De Casteljau result for the midway point on the curve and then I re-constructed the Bezier using Maya's CV curve tool with the tool settings set to Bezier and as you can see they match.

cv_bezier_1.gif

Brent McPherson
Principle Engineer
0 Likes

cglynos
New Member
New Member

Hi brentmc,

 

Thank you for your response and happy new year! 🙂

 

Unfortunately, this is not a Bezier curve. Maya does not seem to be able to create authentic Bezier curves. Every curve seems to be a submodule of NURBS, with knot vectors, etc. A Bezier curve is not a spline and, therefore, does not require knots. If anything, Maya needs to remove the word Bezier from the UI, unless they want to specify that they refer to piecewise beziers, which is a collection of bezier curves that do have knots and C continuities. I have also looked at the C++ API and I couldn't find any reference to Beziers.

 

Also, the "Bezier" curve that Maya creates is almost identical to the NURBS curve. That can only be true if it's a Bezier spline, not a curve, and it has the same exact configurations as a NURBS, i.e. uniform weights, tangents, etc. In which case, why have two types of splines that behave the same way? 

 

For reference, this is what the curve should have looked like:

cglynos_0-1735824148061.png

The green is the correct Bezier curve. 

0 Likes

brentmc
Autodesk
Autodesk
Accepted solution

Ahhhh, you want a 4th order Bezier curve, not a piecewise cubic Bezier.

Here is the script needed to create your 4th order Bezier curve:

 

import maya.cmds as mc
mc.curve(d=4, bezier=1, p=[(-1,0,0),(-1,2,0),(0,1,0),(1,2,0),(1,0,0)])

 


and the resulting curve:
screenshot_000389.png

It is not very common to user higher order curves. Most applications stick with degree 3 or lower since they exhibit better local control. e.g. moving a control point only affects the curve near the control point. You lose this local control as you go to higher degree curves which is why most applications stick with piecewise cubic curves.

Note: It is true that Maya uses NURBS internally as its underlying curve representation since many common spline curves such as Bezier, B-spline, Catmull-Rom and others are subsets of NURBS.

Brent McPherson
Principle Engineer
0 Likes

cglynos
New Member
New Member

Brilliant! That's the code I was looking for. Thank you very much!

0 Likes