Parametrization of Bézier Triangle

1 Ansicht (letzte 30 Tage)
Andrea Baleani
Andrea Baleani am 4 Jul. 2022
I have a procedure that, given a triangular array of points P and positive values such that , finds the point on the Bézier triangle with control points P. This procedure is called "PSDecasteljauT". I would like to parametrize the standard 2-symplex and use such parametrization to plot triangular Bézier surfaces using "PSDecasteljauT".
Until now i came up with some code, but i'd like an easier version with which i can use some triangulations (since i cannot on this one because i set to "nan" all the points in the rectangular grid that don't parametrize the surface).
function [] = SbezierT(P,n)
M=500;
u=linspace(0,1,M);
v=linspace(0,1,M);
for i=1:M
for j=1:M
if u(i)+v(j) <= 1
S(i,j,:)=PSDecasteljauT(P,n,u(i),v(j));
else
S(i,j,:)=nan;
end
end
end
figure;
hold on
surf(S(:,:,1),S(:,:,2),S(:,:,3))

Antworten (1)

sai charan sampara
sai charan sampara am 27 Okt. 2023
Hello Andrea,
I understand that you are trying to replace the missing values (nan) with values based on the neighbouring elements.
One way of doing this is by using “fillmissing2” function of MATLAB. This function operates on 2-Dimensional data that has missing values. The type of interpolation to be done can be passed in as an input to the functional call. In your case once the 3-Dimensional S matrix data is generated with some nan values, data along each dimension x, y and z can be treated as an individual 2-Dimensional matrix and can be passed on to the function. Then the missing values are fixed and a better surf plot is obtained. Here is an example code which uses “fillmissing2”:
S=peaks(25);%example data
surf(S);%original surf plot
idx1=randi(25,3);
idx2=randi(25,3);
S(idx1,idx2)=nan;%removing data from random places of the data
surf(S);%plotting with missing data
S=fillmissing2(S,"nearest");
surf(S);%plot after replacing nan values
There are several other functions like “fillgaps”, “interp2”, etc that can be used for achieving similar results.
You can refer to the below documentations to learn more about such functions.
Hope this helps.
Thanks,
Charan.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by