- “fillmissing2”: https://www.mathworks.com/help/matlab/ref/fillmissing2.html
- “interp2”: https://www.mathworks.com/help/matlab/ref/interp2.html
- “fillgaps”: https://www.mathworks.com/help/signal/ref/fillgaps.html
Parametrization of Bézier Triangle
4 views (last 30 days)
Show older comments
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".
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1053965/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1053970/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1053975/image.png)
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))
0 Comments
Answers (1)
sai charan sampara
on 27 Oct 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.
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!