我想从具有特定值的3D矩阵填充矩形区域,但
我只知道这个矩形的4个顶点。
我该怎么办?
示例:
Grid = zeros (10, 10, 3);
% My vertices points
vx = [1 3 5 3];
vy = [3 5 3 1];
vz = [0 0 0 0];
% I want fill all the surface of rectangle
% with the value [1 0 0] and the edges with [0.5 0.5 0]
答案 0 :(得分:0)
我用 insertShape 函数找到了问题的解决方案 https://fr.mathworks.com/help/vision/ref/insertshape.html
示例:
Grid = zeros (10, 10, 3);
% The coordinates of vertices
vx = [1 3 5 3];
vy = [3 5 3 1];
values = [0.3 0.5 0.2];
Grid = insertShape(Grid ,'FilledPolygon', [ vx(1) vy(1), vx(2) vy(2), ...
vx(3) vy(3) ,vx(4) vy(4)], 'Color' , values );