Devide a plotted line

1 visualización (últimos 30 días)
Tim Schaller
Tim Schaller el 29 de Sept. de 2022
Respondida: Jaiden el 26 de Jun. de 2024
Hey there,
In order to move further with my Bachelorthesis, I need to devide this plotted line into 20 parts. Any part needs to have the exact same distance to the others. The distances need to the same on the plotted line, not just on the x- or y-coordinate.
I hope you understand my question.
Thanks in advance.
n = 3;
n1 = n-1;
a = 20; % Breite des Krummers entlang x
b = 10; % Höhe des Krümmers entlang y
P = [0 b;0 0;a 0]
P = 3×2
0 10 0 0 20 0
syms t
B = bernsteinMatrix(n1,t);
bezierCurve = simplify(B*P);
fplot(bezierCurve(1), bezierCurve(2), [0, 1])
hold on
scatter(P(:,1), P(:,2),'filled')
hold off
  4 comentarios
David Hill
David Hill el 29 de Sept. de 2022
Did you download the function from the file exchange?
Tim Schaller
Tim Schaller el 29 de Sept. de 2022
Okey, now I got it. Thank You
Now I need to figure out a way it works for my example.

Iniciar sesión para comentar.

Respuestas (1)

Jaiden
Jaiden el 26 de Jun. de 2024
To divide the plotted Bezier curve into 20 equal parts, you can follow these steps:
  1. Evaluate the Bezier Curve: You have already defined the Bezier curve using Bernstein polynomials. Let's assume bezierCurve represents the parametric equations of your curve.
  2. Parameterize the Curve: Since the Bezier curve is parameterized by t ranging from 0 to 1, to divide it into 20 equal parts, you need to calculate the parameter t values where these divisions occur.
  3. Calculate Parameter Values: Divide the interval [0, 1] into 20 equal segments. The parameter t values corresponding to these divisions are:ti=i20,for i=0,1,2,…,20t_i = \frac{i}{20}, \quad \text{for } i = 0, 1, 2, \ldots, 20ti​=20i​,for i=0,1,2,…,20
  4. Evaluate Points on the Curve: For each t_i, evaluate the Bezier curve (x(t_i), y(t_i)) to get the coordinates of points that divide the curve.
  5. Plot the Points: Plot these points on the Bezier curve to visualize the divisions.
Here’s how you can implement this in MATLAB:
n = 3
n1 = n - 1
a = 20; % Breite des Krummers entlang x
b = 10; % Höhe des Krümmers entlang y
P = [0 b; 0 0; a 0]
syms t
B = bernsteinMatrix(n1, t)
bezierCurve = simplify(B * P)
fplot(bezierCurve(1), bezierCurve(2), [0, 1])
hold on
scatter(P(:, 1), P(:, 2), 'filled')
num_divisions = 20
t_values = linspace(0, 1, num_divisions + 1); % Divide [0, 1] into 20 parts
curve_points_x = subs(bezierCurve(1), t, t_values)
curve_points_y = subs(bezierCurve(2), t, t_values)
scatter(curve_points_x, curve_points_y, 'r', 'filled')
hold off
Note: Lines in bold represent the lines that you need to add.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by