Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Centroid with Bezier

  1. Jul 9, 2012 #1
    Does anyone have an easy formula for finding the centroid coordinates under a degree 3 bezier curve?

    The whole parametric two variable thing isn't working with the formulas I know of.

    Thanks
     
  2. jcsd
  3. Jul 9, 2012 #2

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    See http://www.infogoaround.org/JBook/Inertia.html (inder "Green's Theorem").

    You wouldn't really expect the formula to be "easy", since you can reparametrize a Bezier curve in arbitrary ways without changing its shape.

    To do it numerically, interpolate points P1, P2, P3, etc along the curve and chop the area into triangles OP1P2, OP2P3, etc where O is the origin (or any other "fixed" point in the plane).
     
  4. Jul 16, 2012 #3
    So,

    Here's my parametric equations:

    x = 3t
    y = 5t^3-9t^2+6t

    I get this when using that formula from the green's therom page:


    X =∫(5x^3-9x^2+6x)^2*3dx = -2.657

    Y = ∫(3y)^2(15y^2−18y+6)dy=2.25

    int from 0 to 1.

    when I load the points in CAD I get:

    x = 1.8
    y = 0.7086

    Which makes sense when you look at it.
    I ran the equations through few other centroid formulas and I don't really get anything consitent. I can find the area pretty easy with parametic integration, but this centroid is giving me trouble.

    Please Help,
    Thanks
     
  5. Jul 16, 2012 #4

    chiro

    User Avatar
    Science Advisor

    Hey jjj888 and welcome to the forums.

    It's going to be easier if you treat this as a centre of mass problem and assume that all points of the curve contribute evenly to the 'mass' of the function.

    We know that to find the centroid you sum all of the values up and divide by the number of values in a discrete case. For the continuous case, we use the density function, but we assume that that the density is the same for all points.

    So you have functions for x and y and given that the density is constant, how would you calculate the centroid from this?
     
  6. Jul 17, 2012 #5
    If the density is constant you would use 1. But I read this somewhere else, and they said to just integrate my original functions normally, which also doesn't give me:
    x=1.5
    y=-1.25
     
  7. Jul 17, 2012 #6

    chiro

    User Avatar
    Science Advisor

    Assume your parameterization is [0,1] region.

    Integrating 3tdt (since x = 3t) over [0,1] gives 3/2 = 1.5
    Integrating 5t^3-9t^2+6t (since y = 5t^3-9t^2+6t) over [0,1] gives 1.25

    These look like the answers above but the y value has the opposite sign.
     
  8. Jul 17, 2012 #7

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Wouldn't the y co-ordinate of the centroid be ∫y.ds/∫ds, where ds2 = dx2+dy2? (And likewise x co-ord.) If so, ds will be dt*√(a quartic in t)
     
  9. Jul 18, 2012 #8
    But,

    As I said above, when I plot the curve out in CAD the centroid cordinates are:

    x = 1.8
    y = 0.7086

    But I can't seem to get this answer. I'm fairly certain this answer is correct, it makes sense when you look at it. Very confusing at this point.
     
  10. Jul 18, 2012 #9

    chiro

    User Avatar
    Science Advisor

    One suggestion I have is to rederive the centroid using delta statements and take the limit to get the calculus definition, just to clarify what the expression should be.
     
  11. Jul 18, 2012 #10
    you're going to have to break that down for me a bit.
     
  12. Jul 18, 2012 #11

    chiro

    User Avatar
    Science Advisor

    Well the centroid is the average of all data points and it is co-ordinate wise.

    So lets say we do it with a spacing of deltax (dx is the limit as it goes to zero).

    The continuous formulation is basically the analog of the expectation formula but there is slight difference: the difference is that the density refers to the number of points that take a particular value.

    So to do this you need to break up the plots of all components (i.e. x and y) into sections that are increasing: you can use the first derivative to do this.

    Then what you do is basically create a kind of 'histogram' of the density of the number of points in a bin with respect to all bins (each bin has the same height when you plot component against the parameter).

    The bin size takes a limit argument to zero and you get a density function from all sections for each component. You then apply the expectation formula to that distribution you calculated where if f(x) gives the probability at x you calculate E[X].

    This will give you the centroid.

    If you want an approximation just a small enough bin size and this will give you a way to get a discrete distribution for each bin and then use the x value as the 'centre' of the bin and use E[X] for X being a discrete random variable.
     
  13. Jul 19, 2012 #12

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    OK, I misunderstood the problem. I thought you wanted the centroid of the curve. In fact, you want the centroid of the lamina bounded by that curve, the x-axis, the y-axis, and the line x = 3, yes?
    xc = ∫Ax.dx.dy/∫Adx.dy
    Adx.dy = ∫t=01y(t).dx(t) = ∫(5t3-9t2+6t).3dt = 3[5t4/4-3t3+3t2]t=01 = 3(5/4-3+3) = 15/4
    Ax.dx.dy = ∫3t(5t3-9t2+6t).3dt = 9∫(5t4-9t3+6t2).dt = 9[t5-9t4/4+2t3] = 9(1-9/4+2) = 27/4
    xc = 9/5, agreeing with CAD.
     
  14. Jul 31, 2012 #13
    Thanks,

    I acctually did find the answer.

    x = 3t
    y = 5t^3-9t^2+6t

    I got the answer using the formula below. This is the first formula I encountered when I started.

    x=1/A∫abxf(x)dx
    y=1/A∫ab(1/2)[f(x)]2dx

    My error was with the area. I used the area under the curve of the parametric equations, but I should have used the area under f(x):

    x=(1/1.25)∫01[3t(5t3-9t2+6t)]dt=1.8
    y=(1/1.25)∫01(1/2)[(5t3-9t2+6t)2]dt=0.70857

    Following the proof of the forluma it makes sence, but I'm still confused as to why it works with the parametric equations.
     
  15. Jul 31, 2012 #14

    chiro

    User Avatar
    Science Advisor

    Hey jjj888.

    You are integrating with respect to each parameter and substituting those values in the integral and since they equivalent, they are giving the same answer. (i.e. y = f(x) = g(t) and x = other function of t).

    What you can do if you want to formalize it is to do an integral substitution and see how the limits change from (a,b) to (0,1).
     
  16. Aug 15, 2012 #15
    Ok so I'm adding on to this a bit.

    I have:
    x=0.9t3+5.1t2
    y=-1.8t3-3.9t2+13.2t

    using :
    x=1/A∫abxf(x)dx
    y=1/A∫ab(1/2)[f(x)]2dx

    for centroid I get:
    x=2.656
    y=2.957

    in cad Iget:
    x=3.371
    y=3.2872
    which makes more sense

    similarly I have:
    x=-0.35t3-0.9t2+8.25t+6
    y=4.4t3-6.6t2+7.5

    for centroid I get:
    x=9.496
    y=3.246

    in cad I get:
    x=9.2657
    y=3.289

    Wich is close but still not the same. Is there some issue with my integration bounds, or is it an issue with the area divisor? I've been playing with this for about a week and now I'm stuck.

    Also, the two curves above link together, is there a way I can find the centroid for these two curves, (cad shows:x=6.6096,y=3.2882) how would I set it up if I had more?

    Thanks
     
  17. Aug 15, 2012 #16

    chiro

    User Avatar
    Science Advisor

    Did you see haruspex's working out above?
     
  18. Aug 15, 2012 #17

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Try writing out your derivation of the first x co-ord in detail (the 2.656) and I'll try to find the error. I get 125.59/37.26 = 3.37.
     
  19. Aug 15, 2012 #18
    I did, but i wasn't too familiar with the notation. I'll take a look again.
     
  20. Aug 16, 2012 #19
    I'm having trouble understanding how
    xc = ∫Ax.dx.dy/∫Adx.dy is equal to x=1/A∫abxf(x)dx?

    Anyway here's my x derivation using x=1/A∫abxf(x)dx:

    x = 1/4.85∫01((0.9t3+5.1t2)(-1.8t3-3.9t2+13.2t)) = 2.656

    I set it up the same way as the previous problem. I would think this is a fairly common problem, that is finding parametric equations to fit curves to things to calculate areas, centers, etc. It's strange I can't find more information about it out there. Obviously it's easily done with computers, but I just like to know how it works.

    Thanks
     
  21. Aug 16, 2012 #20

    haruspex

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    2016 Award

    Ax.dx.dy = ∫A.dy.x.dx = ∫xy.dy.x.dx = ∫xy.x.dx
    What happened to dx? dx is (dx/dt)dt, not dt.
    Let me illustrate just in calculating A:
    A = ∫A.dy.dx = ∫xy.dy.dx = ∫xy.dx = ∫t y.(dx/tx).dt = ∫t (-1.8t3-3.9t2+13.2t).(2.7t2+10.2t).dt = 37.26
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Centroid with Bezier
  1. Bezier Curve Question (Replies: 1)

Loading...