How to generate surface of revolution from Bezier curve
9 views (last 30 days)
Show older comments
I am trying to generate revolved surface from bezier curve. I have generated bezier curve but now I do not know how to proceed further. Please help.
Below is the code that I have written and beyone this point I am stuck.
clc
clear
close all
%% Define inout parameters
B = [1,1; 2,3; 4,3; 3,1]; % Creating matrix for polygon vertices
[r,s] = size(B); % getting size of matrix in terms of rows and columns
n = r-1; % n+1 represents number of vertices of the polygon
np = 20; % represents number of equi-distance points on the bezier curve
t = linspace(0,1,np);
%% Plot polygon
for k = 1:n
plot([B(k,1),B(k+1,1)], [B(k,2),B(k+1,2)], 'r', 'LineWidth', 2)
hold on
grid on
end
%% Generate the points on the bezier curve
for j = 1:np
P = [0,0];
for i = 0:n
M(i+1) = (factorial(n)/(factorial(i)*factorial(n-i)))*((t(j))^i)*((1-t(j))^(n-i));
P = P + B(i+1,:)*M(i+1);
end
Q(j,:) = P;
end
%% Plot the bezier curve from the obtained points
for l = 1:np-1
plot([Q(l,1),Q(l+1,1)],[Q(l,2),Q(l+1,2)], '-- b', 'LineWidth', 2);
hold on
end
0 Comments
Answers (1)
Amish
on 30 Oct 2023
Hi Jinesh,
I understand that you are trying to create a surface by revolving the Bezier curve that you have made. The approach that I see in your code is that you are generating a fixed number of points that satisfy the equation and then plotting them. You can try to similarly do this for the case of 3D coordinates too if you already have control points for the curve available at hand.
The following MATLAB File exchange uses the similar algorithm and plots the 3D surface for the curve. I would request you to have a look at this: https://www.mathworks.com/matlabcentral/fileexchange/66678-bezier-surface
Hope this helps!
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!