cd cam

Version 1.0.0 (9,05 ko) par Ali Zwahreh
assignment
3 téléchargements
Mise à jour 16 déc. 2021

Afficher la licence

% the aim of this program is to plot both hermite & Bezier curves
%hermite curve will work for just three points
clear;
clc;
p=input('enter the number of contol points');
for i=1:p
px(i)=input('enter the x component of point');
py(i)=input('enter the y component of point');
end
%I will start with Bezier curve
%the next step is just to make the curve good looking and c could be any
%value but 1 so it is to ma;
c=input('the number of output points (50) of the curve');
u=0:1/(c-1):1;
for i=1:p
a(i)=(factorial(p-1))/((factorial(i-1))*(factorial(p-i)))
end
%next i will write the first and final control point so it will appear on
%the v=command window.
bx(1)=px(1);
bx(c)=px(p);
by(1)=py(1);
by(c)=py(p);
zx(1)=px(1);
zy(1)=py(1);
zx(c)=px(p);
zy(c)=py(p);
%the next j loop is to define the u variable and we can start it from
%any positive number and to make a loop for plotting x;y
for j=2:c-1
x=0;
y=0;
l=0;
d=0;
for i=1:p
kx(i)=a(i)*((u(j))^(i-1))*((1-u(j))^(p-i))*px(i);
ky(i)=a(i)*(u(j)^(i-1))*((1-u(j))^(p-i))*py(i);
if p==2||p==3
fx=[((u(j))^3)-((u(j))^2)-u(j)+1 -((u(j))^2)+u(j) -u(j)^3+2*u(j)^2]*[px(1);px(2);px(3)];
fy=[u(j)^3-u(j)^2-u(j)+1 -u(j)^2+u(j) -u(j)^3+2*u(j)^2]*[py(1);py(2);py(3)];
l=fx;
d=fy;
end
x=x+kx(i);
y=y+ky(i);
end
zx(j)=l;
zy(j)=d;
bx(j)=x;
by(j)=y;
end
g=input('enter any value of u')
if g<=1 && g>=0
for i=1:p
nx=a(1)*((g)^(1-1))*((1-g)^(p-1))*px(1)+a(2)*((g)^(2-1))*((1-g)^(p-2))*px(2)+a(3)*((g)^(3-1))*((1-g)^(p-3))*px(3);
ny=a(1)*((g)^(1-1))*((1-g)^(p-1))*py(1)+a(2)*((g)^(2-1))*((1-g)^(p-2))*py(2)+a(3)*((g)^(3-1))*((1-g)^(p-3))*py(3);
mx=[(g)^3-(g)^2-g+1 -(g)^2+g -(g)^3+2*(g)^2]*[px(1);px(2);px(3)];
my=[(g)^3-(g)^2-g+1 -(g)^2+g -(g)^3+2*(g)^2]*[py(1);py(2);py(3)];
end
end
plot(px,py)
hold on
plot(zx,zy,'k')
plot(nx,ny,'b*')
plot(bx,by,'r')
plot(mx,my,'b*')
hold off

Citation pour cette source

Ali Zwahreh (2024). cd cam (https://www.mathworks.com/matlabcentral/fileexchange/103665-cd-cam), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2021b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Tags Ajouter des tags
Remerciements

Inspiré par : CAD APPS

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0