Jump to content


- - - - -

Curves! Lagrange und Bézier


10 replies to this topic

#1 oscarfh

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 17 January 2009 - 07:04 PM

Hello,
I am studying Compter Graphics, and I have a task that I have to do, but I am stuck:
I have this curve
Posted Image
That was generated with Lagrange.
with the points:
p0=(-2,0)
p1=(-1,0)
p2=(0,3)
p3=(1,0)
p4=(2,0)
and
u0=0
u1=1/4
u2=1/2
u3=3/4
u4=1

What I have to do is: calculate the points to generate a curve that matches this one, but using Bézier. Like this picture:
Posted Image

But I don't know exactly the points. How can I calculate it?

Also I have to do the oposite: I have a curve with Bézier and I have to generate a curve with lagrange to match the curve with Bézier.

Thank you,
Oscar

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5305 posts
  • LocationBellevue, WA

Posted 17 January 2009 - 10:46 PM

Hi Oscar,

Please be aware that we don't normally answer 'homework questions' on this site. If this is a task for a class, you should consult your professor and/or classmates for help.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 oscarfh

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 18 January 2009 - 10:23 AM

Hi,
I know that in the site you don't do homework for others. But I think that answering questions that we may have when doing the homework is not something bad. And this is exactaly what I want: just some help so I can start, because now I am stuck, I don't want anybody doing this calculation for me.
If It is possible to be done (answering these questions) I would be very happy. If it is not, I understand.

Thank you,
Oscar

#4 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 510 posts
  • LocationNowhere whenever

Posted 18 January 2009 - 11:53 AM

If you want help, you have to show that you're trying to solve it yourself, and not just ask for the solution. In other words, ask smarter questions.

Often you'll find that when you find the correct questions to ask, the answer is trivial.

"How can I calculate it?" isn't smart enough.
http://iki.fi/sol - my schtuphh

#5 oscarfh

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 18 January 2009 - 12:47 PM

Ok, I don't know how to start it, I am stuck.
I will keep trying to go further and when I get something I will come back.

Thank you :)
Oscar

#6 oscarfh

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 18 January 2009 - 06:14 PM

Hey, it is me again.
So I spent the aftoernoon looking for some answer but I cound't find. I will not list everything that I tried, but I got to no place, I will exaplain two solutions that I am planning to work into. But before, one question:
I have this "formula":
Posted Image

What exactly it means for (1-t)^3 or t^3? I just didn't understand.

Ok, now what I'm planning to do:
for some of the previous exercises I had to calculate the transformation matrix from Monomial to bezier basis:

Posted Image

and also calculated the monomial to lagrange basis.

As far as I understood, if I have the monomial to bezier matrix, I can calculate the bezier to monomial matrix this way:
Posted Image

So, will it work if, to go to Bezier to Lagrange I multiply
TM<-B * TL<-M ?

and to go from Lagrange to Bezier I multiply:
TM<-L * TB<-M?

Does that make sense?

If this assumption is incorrect, my other idea is to find the points where the tangent signal changes in the graphic and then using this points to try to calculate the control points. Does it make sense?

Thank you,
Oscar

#7 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 575 posts

Posted 18 January 2009 - 09:51 PM

oscarfh said:

Hey, it is me again.
So I spent the aftoernoon looking for some answer but I cound't find. I will not list everything that I tried, but I got to no place, I will exaplain two solutions that I am planning to work into. But before, one question:
I have this "formula":
Posted Image

What exactly it means for (1-t)^3 or t^3? I just didn't understood.

TBH I'm lost as to how you can calculate a spline basis transform and not understand some pretty basic polynomials ... So I'm assuming you've not explained your question very well.

t is just the spline interpolator. Vary the t from 0 -> 1 and you get the points along the curve (0 is the start, 1 is the end). plug in the t value and you get your positions back.

Its quite possible that you are getting confused between the parametric form and the basis matrix.

The wikipedia page on bezier curves is very informative ... I'm shocked you haven't read through it.

Quote

Ok, now what I'm planning to do:
for some of the previous exercises I had to calculate the transformation matrix from Monomial to bezier basis:

Posted Image

and also calculated the monomial to lagrange basis.

As far as I understood, if I have the monomial to bezier matrix, I can calculate the bezier to monomial matrix this way:
Posted Image

So, will it work if, to go to Bezier to Lagrange I multiply
TM<-B * TL<-M ?

and to go from Lagrange to Bezier I multiply:
TM<-L * TB<-M?

Does that make sense?

If this assumption is incorrect, my other idea is to find the points where the tangent signal changes in the graphic and then using this points to try to calculate the control points. Does it make sense?

Yup .. that makes perfect sense. Though bear in mind that the order of multiplications changes if you are using column major over row major matrices. Pretty easy to test it out and see what happens though ;)

#8 oscarfh

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 19 January 2009 - 12:48 AM

Ok, this is what I have until now:
with the points:
p0=(-2,0)
p1=(-1,0)
p2=(0,3)
p3=(1,0)
p4=(2,0)
and
u0=0
u1=1/4
u2=1/2
u3=3/4
u4=1

With that I got:
I used this formula to calculate Bézier Matrix:
Posted Image
with
Posted Image
With that, I got:
Posted Image
Also:
Posted Image
And then the matrix:
Posted Image

For Lagrange I have this formula:
Posted Image
And then got these results:
Posted Image

Which led me to this matrix:
Posted Image

As long as:
Posted Image

then:
Posted Image
and
http://img.photobuck...1/oscar/tml.jpg

then I used these formulas:
http://img.photobuck...acaoformula.jpg

(Is the order correct? How can I check it?)

And got these results:
http://img.photobuck...1/oscar/tbl.jpg
and
http://img.photobuck...1/oscar/tlb.jpg

-I am not sure if the order of the multiplication of the matrixes is correct. how can I check it?
-One thing that I noticed is: if you sum the elements inside the lines for the matrixes TL<-M and TB<-M, except for the last line, it will always result 0. Is it a property or something?
-And the last question: from the matrixes TB<-L and TL<-B I can get some equations. But how can I, from these equations or form the matrix, get the control points?

thank you again for your help,
Oscar

#9 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 19 January 2009 - 01:25 AM

Yea - I know I'm running into the risk to confuse you even more, but I think you can do easier. I only had a brief look at your approach and it seems okay, but how about this:

You've converted your points to a lagrande polynomial. This polynomial can be written in the standard form. e.g.

f(x) = a*x^4 + b*x^3 + c*x^2 + d*x + e (shown for order 4).

Now you want to have a bezier curve for that polynomial.

I could be wrong, but I think all you have to do is to project the polynomial onto the bernstein-polynomials and you get your bezier coefficients out. No matrices involved.

That "project onto polynomial" thing sounds super mathematical, but it's easy in practice. If I remember right it was just applied polynomial division.

Guys, any idea if this works? I'm unsure myself (just thinking out loud).
My music: http://myspace.com/planetarchh <-- my music

My stuff: torus.untergrund.net <-- some diy electronic stuff and more.

#10 Reedbeta

    DevMaster Staff

  • Administrators
  • 5305 posts
  • LocationBellevue, WA

Posted 19 January 2009 - 02:44 AM

It sounds reasonable to me. But projection onto a basis of Bernstein polynomials can be just as well expressed with matrices as with polynomial division, since polynomials can be seen as a vector space, and projection as a matrix operation on that vector space.
reedbeta.com - developer blog, OpenGL demos, and other projects

#11 oscarfh

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 19 January 2009 - 12:22 PM

Hi,
Let me show what I understood and did.
First of all, I defined the polynomials in the form:
Posted Image
Posted Image

Then I tried to divide each "section" from Lagrange by Bezier:
(By section I mean the x0 is one sextion, the x1 another and so on):

Posted Image
Posted Image

It is not matching what I have, I will keep on trying to understand it.
But I can get a polynomial by the matrixes calculated in the last post. But what would I do with it? How would I get the points?

What I did was to get from the TB<-L matrix the first row, which is related to the X0.
Then I got these equations
Posted Image

Theretically it would give me the "new X0", in the bezier formula to fit the lagrange curve, but I don't know the values for t!

thank you,
Oscar





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users