⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 and.m

📁 一个matlab的将军模型
💻 M
字号:
function I = and(v1,v2)

% Find the intersection of two vertices objects 
%
% Syntax:
%   "V = and(a,b)"
%
%   "V = a & b"
%
% Description:
%   "and(a,b)" returns a vertices object constructed from all points
%   contained in both "a" and "b".  "b" can be given as a list of points
%   which is then converted to a vertices object before finding the
%   intersection.
%
% Examples:
%   Given two vertices objects, "a" representing a square in the x3 = 0
%   plane with corners at (x1,x2) pairs (2,1), (2,3), (4,3), and (4,1)
%   and "b", another square in the same plane with corners at (2,1),
%   (2,2), (3,1), and (3,2),
%
%
%
%   "V = and(a,b)"
%
%
%
%   returns "V", a vertices object containing the (x1,x2) pair (2,1). 
%
% See Also:
%   vertices

global GLOBAL_APPROX_PARAM

I = vertices;
if ~isa(v2,'vertices')
  v2 = vertices(v2);
end

if (length(v1) > 0) & (length(v2) > 0) & (dim(v1) ~= dim(v2))
  disp('VERTICES/OR: different dimensions given')
  return
end
  
point_tol = GLOBAL_APPROX_PARAM.poly_point_tol;

N1 = length(v1);
N2 = length(v2);

if (N1 == 0) | (N2 == 0)
  return
end

list = [];
for k = 1:N1
  v1k = v1.list(:,k);
  for l = 1:N2
    v2l = v2.list(:,l);
    diff = (v1k-v2l);
    if (diff'*diff < point_tol)
      list = [list v1k];
      break;
    end
  end
end
I = vertices(list);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -