Define a variable on a spline

2 visualizaciones (últimos 30 días)
Tim Schaller
Tim Schaller el 7 de Oct. de 2022
Editada: Matt J el 7 de Oct. de 2022
Hey there,
My problem is, that I have a spline and I need to get a variable that follows the line.
n = 3;
n1 = n-1;
a = 20;
b = 10;
P = [0 b;0 0;a 0];
x = P(:,1);
y = P(:,2);
T = 20;
syms t
B = bernsteinMatrix(n1,t);
bezierCurve = simplify(B*P);
fplot(bezierCurve(1), bezierCurve(2), [0, 1])
axis equal
grid on
hold on
scatter(x,y,'filled')
hold off
arclen = arclength(px,py) %You need the arclength function there for
In this example the variable needs to have the value 0 on the point (0 10) and it needs to have the value of the arclength in point (20 0)
I hope you guys have some great ideas.
Thank You!

Respuesta aceptada

Matt J
Matt J el 7 de Oct. de 2022
Editada: Matt J el 7 de Oct. de 2022
n = 3;
n1 = n-1;
a = 20;
b = 10;
P = [0 b;0 0;a 0];
x = P(:,1);
y = P(:,2);
T = 20;
syms t
assume(t>=0 & t<=1)
B = bernsteinMatrix(n1,t);
bezierCurve = simplify(B*P);
arclength(t)=int(norm(diff(bezierCurve)),0,t)
arclength(t) = 
double(arclength(0))
ans = 0
double(arclength(1))
ans = 24.8865

Más respuestas (1)

Torsten
Torsten el 7 de Oct. de 2022
n = 3;
n1 = n-1;
a = 20;
b = 10;
P = [0 b;0 0;a 0];
x = P(:,1);
y = P(:,2);
T = 20;
syms t
B = bernsteinMatrix(n1,t);
bezierCurve = simplify(B*P);
fun = int(sqrt(diff(bezierCurve(1),t)^2+diff(bezierCurve(2),t)^2),0,t);
subs(fun,t,0)
ans = 
0
subs(fun,t,1) % Arclength of curve between the two points (0 10) and (20 0)
ans = 

Categorías

Más información sobre Splines en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by