Sign in to follow this  

Bezier triangle partial derivatives

This topic is 2050 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

Hello I am trying to compute the partial derivatives of a bezier triangle (in u and v directions).

I followed this article to build my program.

[url="http://www.gamasutra.com/view/feature/131389/b%C3%A9zier_triangles_and_npatches.php?print=1"]http://www.gamasutra...hes.php?print=1[/url]

The section that interest me is "[b]Derivatives [triangles]:"[/b]

[img]http://www.gamasutra.com/features/20020715/beq4.gif[/img]

question 1 : In the equations... does "p" refer to the actual control points of the triangle?

If this is the case, it seems like the derivative takes into account only 6 of the 10 control points of the patch... Is this normal?

the coefficients computed are for i+j+k=2 so if I plug theses values in the bernstein polynomial definition I get the following coefficients :


i=0, j=0, k=2 ---> w * w
i=0, j=2, k=0 ---> v * v
i=2, j=0, k=0 ---> u * u
i=1, j=1, k=0 ---> 2 * u * v
i=1, j=0, k=1 ---> 2 * u * w
i=0, j=1, k=1 ---> 2 * v * w

question 2 : this seems to contradict another section of the article where a bernstein of degree two is used for indices 110, 101, 011 and there is no x2 multiplication... Is this normal?

[img]http://www.gamasutra.com/features/20020715/eq4s.gif[/img]

Hopefully someone can clarify this... I really need theses derivatives.

Thanks,

Shnoutz. Edited by Shnoutz

Share this post


Link to post
Share on other sites
Hi,

[quote name='Shnoutz' timestamp='1336033589' post='4937014']
question 1 : In the equations... does "p" refer to the actual control points of the triangle?
[/quote]
According to the terminology used so far, I’d say yes.

I found an [url="http://cagd.cs.byu.edu/~tom/papers/pac.pdf"]old paper by Sederberg[/url], which has a graphical explanation for the definition of directional derivatives (Fig. 14). The figure depicts the construction of the derivative patch in w-direction (w=const). The construction for the patches in u- and v-direction is similar. Though, it has a little error in there, I think. The top and top left control points are substituted, but I think you can get the gist.

[quote name='Shnoutz' timestamp='1336033589' post='4937014']
If this is the case, it seems like the derivative takes into account only 6 of the 10 control points of the patch... Is this normal?
[/quote]
It’s expected that the degree of the “derivative patch” goes down, so 6 points instead of 10 seems right. If you derive a polynomial of degree n the outcome is a polynomial of degree n-1.

[quote name='Shnoutz' timestamp='1336033589' post='4937014']
i=2, j=0, k=0 ---> u * v
[/quote]
Little typo, it’s u*u

[quote name='Shnoutz' timestamp='1336033589' post='4937014']
question 2 : this seems to contradict another section of the article where a bernstein of degree two is used for indices 110, 101, 011 and there is no x2 multiplication... Is this normal?
[/quote]
This is indeed a little strange. I’d have expected the factor 2, too.
Well, after all, this article seems not to be peer-reviewed, so little errors might be possible. I’d suggest to pick up a book of Farin, e.g. “Curves and Surfaces for CAGD: A Practical Guide” (Chapter 17) if you want to learn more.

Cheers!

Share this post


Link to post
Share on other sites
Thank you Tsus,

I manually derived the position equation to find the partial derivatives...

[img]http://www.gamasutra.com/features/20020715/beq2.gif[/img]
[img]http://www.gamasutra.com/features/20020715/beq3.gif[/img]

For n=3 the code looks like this :

[code]
float3 bezierTriangle(float3 uvw, float3 points[10])
{
return
uvw.x * uvw.x * uvw.x * points[P300] +
uvw.y * uvw.y * uvw.y * points[P030] +
uvw.z * uvw.z * uvw.z * points[P003] +
3.0f * uvw.x * uvw.x * uvw.y * points[P210] +
3.0f * uvw.y * uvw.y * uvw.z * points[P021] +
3.0f * uvw.z * uvw.z * uvw.x * points[P102] +
3.0f * uvw.y * uvw.y * uvw.x * points[P120] +
3.0f * uvw.z * uvw.z * uvw.y * points[P012] +
3.0f * uvw.x * uvw.x * uvw.z * points[P201] +
6.0f * uvw.x * uvw.y * uvw.z * points[P111];
}
[/code]

...And the derivatives in u and v are :

[code]
float3 bezierTriangle_du(float3 uvw, float3 points[10])
{
return
3.0f * uvw.x * uvw.x * (points[P300] - points[P201]) +
3.0f * uvw.y * uvw.y * (points[P120] - points[P021]) +
3.0f * uvw.z * uvw.z * (points[P102] - points[P003]) +
6.0f * uvw.x * uvw.y * (points[P210] - points[P111]) +
6.0f * uvw.x * uvw.z * (points[P201] - points[P102]) +
6.0f * uvw.y * uvw.z * (points[P111] - points[P012]);
}

float3 bezierTriangle_dv(float3 uvw, float3 points[10])
{
return
3.0f * uvw.x * uvw.x * (points[P210] - points[P201]) +
3.0f * uvw.y * uvw.y * (points[P030] - points[P021]) +
3.0f * uvw.z * uvw.z * (points[P012] - points[P003]) +
6.0f * uvw.x * uvw.y * (points[P120] - points[P111]) +
6.0f * uvw.x * uvw.z * (points[P111] - points[P102]) +
6.0f * uvw.y * uvw.z * (points[P021] - points[P012]);
}
[/code]

As we can see, the derivatives for a degree 3 Bezier triangle is a degree 2 Bezier triangle... But the control points are not like they describe in the article.

We actually use 9 of the 10 initial control points to make 6 new ones.

I guess it could be written like this :

[attachment=8769:du.jpg]
[attachment=8770:dv.jpg]

I also compared the results of adding a a factor 2 to the original N-Patch normal equation... Obviously, it still works without it but I think I looks better with the factor 2.

[attachment=8771:n.jpg]

Share this post


Link to post
Share on other sites

This topic is 2050 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this