# Find the derivative of a spline curve obtained using cscvn

10 vues (au cours des 30 derniers jours)
Taleb le 16 Mai 2023
Modifié(e) : Torsten le 17 Mai 2023
Im trying to get the derivative of a 3D spline curve obtained with the cscvn function, I found that you can use fnder to obtain the derivative, but they use other spline methods (which are in 2D). If there is no way to obtain the derivative, can I at least get the function of the spline?
Here is my code:
xyz=[-15.3388,-13.9258,-12.5000,-7.5,0, 15;-29.7289,-29.9321,-30,-30, -30,-30; 34.5601, 35.2764, 36, 37.5, 40,40];
plot3(xyz(1,:),xyz(2,:),xyz(3,:),'ro');
box on
hold on
spline_func=cscvn(xyz(:,[1:end]));
spline_func.coefs
ans = 15×4
-0.0305 0 1.1668 -15.3388 0.0159 0 -0.1862 -29.7289 0.0013 -0.0000 0.5646 34.5601 0.1578 -0.1156 1.0207 -13.9258 -0.0125 0.0603 -0.1100 -29.9321 -0.0034 0.0051 0.5711 35.2764 -0.0770 0.4834 1.4860 -12.5000 -0.0023 0.0129 -0.0173 -30.0000 0.0206 -0.0080 0.5674 36.0000 0.0385 -0.0446 2.4887 -7.5000
fnplt(spline_func,'r',2)
sp_df=fnder(spline_func,1);
sp_df.coefs
ans = 15×3
-0.0914 0 1.1668 0.0477 0 -0.1862 0.0040 -0.0000 0.5646 0.4735 -0.2311 1.0207 -0.0375 0.1206 -0.1100 -0.0103 0.0102 0.5711 -0.2311 0.9668 1.4860 -0.0070 0.0259 -0.0173 0.0617 -0.0160 0.5674 0.1154 -0.0892 2.4887
fnplt(sp_df)
grid on
xlabel('x(t)')
ylabel('y(t)')
zlabel('z(t)')
hold off The sp_df returns a structure that has different fields, form, breaks, coefficients, pieces, order, and dimension, does anything of these has relation to the derivative?
The yellow graph is supposed to be the derivative" but I want to see the a table of the values.
##### 2 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Taleb le 17 Mai 2023
Thanks Torsten! I appreciate the help! this was what I was looking for, I couldn't find much on the form of the function so I couldn't find the meaning of the coefficients. Have a good day mate!

Connectez-vous pour commenter.

### Réponses (1)

John D'Errico le 16 Mai 2023
No. There is no simple "function" of a spline. It is a mess of coefficients that by themselves are fairly meaningless to those who don't fully understand splines. And even if you do understand them, even I won't gain much useful information by looking at them. Just a slew of numbers. And if you are asking to know the "function", then you don't understand splines. (Hey. I'm sorry, but this is the truth.)
Anyway, what is the derivative of a function that falls along some general curved path through space? What derivative are you hoping to see? Derivative, with respect to what? Yes, you can compute a derivative. But remember what I just asked. What exactly are you hoping to compute?
The curve computed by cscvn is a parametric function of what I call the connect-the-dots arc-length along the curve. As I recall, it is a version of a centripetal Catmull-Rom spline.
So, again, what are you trying to compute? Remember the definition of derivative.
##### 1 commentaireAfficher AucuneMasquer Aucune
Taleb le 16 Mai 2023
No worries, I do not know what a spline is honestly, I just used the method to complete a task I was given. The point behind this task is to do different segments of a roller coaster and then put them together, being that the segments are continuous and smooth. The derivative is to respect to time, I want to obtain the tangent and normal vectors of the rollercoaster.
I ended up using this method since I had a hard time joining the different curves I have and figured this would be an easier way to do it but I guess I have to find another alternative.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Spline Construction dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!