Matlab具有插值功能的面片函数会根据顶点的顺序产生不同的结果 [英] Matlab's patch function with interpolation produces different result based on order of vertices

查看:139
本文介绍了Matlab具有插值功能的面片函数会根据顶点的顺序产生不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个x,y,c坐标的补丁,如下所示.更改点的顺序后,MATLAB的patch颜色插值会更改.

I have a patch with x,y,c coordinates as given below. Upon changing the order of points, MATLAB's patch color interpolation changes.

x = [0.9000    1.0000    1.0000  0.9000]';
y = [0.5000    0.5000    0.6000  0.6000]';
c = [0.0278    0.0371    0.0325    0.0282]';

figure();
patch(x,y,c);

order = [2:4,1];
figure();
patch(x(order),y(order),c(order));

以上内容产生两个不同的色块.但是,坐标和颜色仅以循环方式更改了序列. 有什么建议可以克服吗?

The above produces two different color patches. However, the coordinates and the color have only changed the sequence in cyclic manner. Any suggestions to overcome this?

推荐答案

我认为这是因为您没有关闭补丁程序-如果补丁程序中的最后一个点与第一个点不同,MATLAB会自动关闭它.显然,这对颜色插值做了一些奇怪的事情.如果您稍微修改代码以关闭补丁,就像这样:

I think that this is because you're not closing your patch -- if the last point in your patch is not the same as the first point, MATLAB automatically closes it. Apparently this does something strange with the color interpolation. If you modify the code slightly so that your patch is closed, like so:

figure;
order = [1:4,1];
patch(x(order),y(order),c(order));
figure;
order = [2:4,1:2];
patch(x(order),y(order),c(order));
figure;
order = [3:4,1:3];
patch(x(order),y(order),c(order));

然后您每次都会获得相同的补丁.

Then you get the same patch every time.

这篇关于Matlab具有插值功能的面片函数会根据顶点的顺序产生不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆