Devide a plotted line
1 回表示 (過去 30 日間)
古いコメントを表示
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]
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 件のコメント
回答 (1 件)
Jaiden
2024 年 6 月 26 日
To divide the plotted Bezier curve into 20 equal parts, you can follow these steps:
- 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.
- 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.
- 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
- 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.
- 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.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!