## 345 Reputation

9 years, 143 days

## @Carl Love  Thank you for your help...

Indeed, I would prefer an explicit symbolic function because I need in a second step to implement my maple code in MapleSim.

## @tomleslie  Hello, For the moment, ...

Hello,

For the moment, I have used all the codes for which you have help me.

For the plot, you are right i forgot to correct this, but my mistake is belore. I try to correct with this plot1 := plot({[Courbe,t=0..6.99]}): and Courbe should be a vector containing 2 polynomes : one for x(t) and one for y(t).

The point was that i wanted to a piecewise function for the definition of the polynomial curve. In this program, this strategy is used. I also supply the definition of the theory that I would like to implement.

There are still some few errors at the end of the program. But, if you look at it in more details, i'm sure you find it far more easy to understand. Namely, it is more clear haow a spline is built and how the polynomial curve is built from the splines.

I hope that you will understand why I send you these news elements (the elements of theory which describes the construction of the polynomial curve and this new code). I try to do my best with my current knowledge with Maple.

I will be very grateful if you can have a look in more details of this last code. I promise you that I will do a detailled sum up of the results obtained with the 2 codes. Having this code working will enable me to better explain what the link between the theory of polynomial curve and its implementation of Maple and next, to show the elements which were missing for me for more clarity in the first code.

## @tomleslie  Hello, Thank you again ...

Hello,

Here the piecewise polynomial curve with Catmull-rom splines that I try to implement :

The polynomial curve with Catmull-splines is defined as a piecewise function with the Catmull-Rom splines. By construction (Catmull-rom splines), the different splines are continuous for the function and its derivative.

With the help of this web page
http://www.dgp.toronto.edu/~elf/2505/maple.html

I almost obtain the code desired so as to match points with this kind of polynomiale curve.

I have still some problems at the end of my code but it should be slight mistakes.

May you have a look to see if you can see these mistakes ?

Here is my code :

CalculSplineMatmull-Rom_version_toronto_4bis.mw

Thanks a lot for your help.

## @Carl Love  Thank you carl for you ...

Thank you carl for you very pedagogical remark. It's indeed very helpful for me.

## @tomleslie Perfect ! Thanks a lot f...

Perfect ! Thanks a lot for your help.

I have indeed make a mistake on the definition of n which is defined as a function in the book and wasn't defined like this in my code.

I have corrected by using unapply function.

Now, i do obtain the same results than in the book.

I attach here the last version of my code:

CalculSplineMatmull-Rom.mw

However, there are some lines that I didn't understand which are :

pp:=n[0](t-i+1)*M[i-1]+n[1](t-i+1)*M[i]+n[2](t-i+1)*M[i+1]+n[3](t-i+1)*M[i+2];
return evalm(sum((1+signum(-t+i))*(1+signum(t-i+1))/4*pp,
i=1..Num-2
)
):

Normally, I guess these lines enable the definition of the curve with the Catmull-Rom splines. But, I didn't understand the operation of it namely the 2 following points :
- why it used the index (t-i+1) in the defintion of pp ?
- how the return function works? I have seen the help, but i didn't seen any examples which makes me difficult to understand for me.

Otherwise, the definition of the polynomial curve defined with Catmull-Rom splines which I would like to implement works normally like this :

You takes 4 points (M1M2M3M4). The polynomial curve obtained with the Catmull-Rom splines is a curve between the point M2 and M3 (match with M2 and M3.

Next, you takes 4 others points (M2M3M4M5). The polynomial curve obtained with the Catmull-Rom splines is a curve between the point M3 and M4 and so on.

Here a picture to illustrate how the Cadmull-Rom splines works:

I think that the use of the function "piecewise" should be adapted to the definition of this polynomial curve with Catmull-rom splines.

May you help me to implement this polynomial curve with a piecewise function in Maple ?

This way can be more easy to understand (because simpler) than the solution proposed in this book.

Thanks a lot for your help

## @tomleslie  Thanks a lot for your h...

Thanks a lot for your help.

You were right, I have forgotten that I have changed the name of the procedure.

I have taken all your remarks into account.

However, I didn't obtain yet the result obtained in the book which is :

Here you can find my code :

CalculSplineMatmull-Rom.mw

1) May you see if you have ideas why I didn't the curves expected ?

2) Otherwise, normally, the different polynoms that I need to define with piecewise function are :

For the moment, in the lines seem to be programmed like this in my code :

pp:=n[0](t-i+1)*M[i-1]+n[1](t-i+1)*M[i]+n[2](t-i+1)*M[i+1]+n[3](t-i+1)*M[i+2];
return evalm(sum((1+signum(-t+i))*(1+signum(t-i+1))/4*pp,
i=1..Num-2
)
):

I have difficulties to understand the code lines.

Do you have ideas so that I can understand the link with the polynoms that I have to define with Catmull-rom splines ?

## I manage to select only the ZeroCrossing...

I manage to select only the ZeroCrossing values with a positive derivative with the slight modification in italic and underlined.

Here my code:

ZerosFrontMontant:= proc(A::Matrix)
local Z:= table(),k;
for k to op([1,1], A)-1 do
if A[k,2]*A[k+1,2] <= 0 and A[k,2]<A[k+1,2] then
Z[k]:= (A[k,1]*A[k+1,2] - A[k+1,1]*A[k,2])/(A[k+1,2]-A[k,2])
end if
end do;
convert(Z, list)
end proc:
for i to 4
do
Pz[i]:=ZerosFrontMontant(Matrix([<tk>,<vvals[i]>]));
LignesVerticales[i]:=plot([seq([Pz[i][j],t,t=-0.05..0.2],j=1..nops(Pz[i]))],colour=orange,linestyle=3, thickness=2,view=[0..2,default]):
od:

## @Carl Love  Great! Thank you for yo...

Great! Thank you for your help.

2) You process is perfect. But, i notice that i still need some modifications in order to select only the zero crossings with a increasing value that is to say with a positive derivates.

The point is that with a explicit parametric curve i could obtain easily the derivative and so select the desired zero crossings. Here, i have difficulties to reduce the zero-crossings to the zero-crossings with a positive derivative. May you help me to modify you procedure so as to obtain the zero-crossings which have a positive derivative?

thanks a lot for your help.

## @tomleslie  Hello, in fact, i could...

Hello,

in fact, i could obtain the plot of the vertical points.

But, I'm still blocked for the determination of the zero crossing values. In fact, for the moment, i could obtain them only for a explicit parametric curve with a Roots function or solve function.

But, i didn't find the zero crossing values for the non linear oscillator. Consequently, it will great if you can give me a last tip for this point.

Thanks a lot for your help. You have learn me a lot of thing.

## @Preben Alsholm  I haven't understa...

I haven't understand yet. But, it works perfectly! Great !

May you precise the syntax that Maple uses to make this plot ? I mean the arguments used by the plot function so as to obtain the result.

The point which troubles me is the fact that it is a bit like if you have a sequence for the t variables (on y-axis) but there is no sequence for t variable.

Thank you Preben for your help.

For the plot of the vertical lines, I try this plot([seq(x=Pz[i],i=1..nops(Pz))],x=0..2, colour=yellow,linestyle=3, thickness=2): but it doesn't work yet.

Do you have ideas what's wrong in this syntax ?

## @Preben Alsholm @Thomas Richard Tha...

Thank you Preben for your ideas

But, the point is that I need to define the functions because I use these functions in the rest of my worksheet. That's why it seems to me that the solution with evaln can be relevant, doesn't it ?

## @tomleslie OK. Thank you for your c...

OK. Thank you for your comments on indentation. For my culture, can you tell me the external editor that you use?

Otherwise, I'm trying now to find the zero-crossings with a increasing curve.

Similarly in gaitPlot4.mw, I calculated a whole sequence of values for each of v[i](t): from this data, it is relatively trivial to work out a pretty good approximation to the zero-crossings (with a little bit of interpolation, if necessary).

I try to find a function similar to max function so as to find the closest value to zero in a list of numerical values. But, i haven't find yet.

I try this but I find not all the solutions and the results is quite strange.

assign(v[1],rhs(res[6]));
Roots(v[1](t)=0,t=0.5..2);
[-0.2526518250e-1]

I also try this : select(s->abs(s)<0.1,vvals);

but it also fails.

Thanks a lot for your help.

## I find a solution : with(Student[Calculu...

I find a solution :

with(Student[Calculus1]):
Roots(v(t),t=0.5..2);

Nevertheless, I'm interesting by your experience on this subject.

## Sorry, for not having upload the last ve...

Sorry, for not having upload the last version of my worksheet.

I do use all your remarks and I thank you for your tips.

For the last attachment, I wanted to focuse on the display of the points. That's why i didn't send you the whole code but I have used all your modifications about vSpace and it works well.

For the display of the points, you perfectly answer to my question.

These code lines have enabled to evaluate the u[i] and v[i].

seq( assign(u[j], rhs(res[j+1])) , j=1..4);
seq( assign(v[j], rhs(res[j+5])) , j=1..4);

Nota: I notice that you indentation in your code. Do you have an automatic way to make code lines with indentation ?

Thank you

 5 6 7 8 9 10 11 Last Page 7 of 16
﻿