cliplin2.m
来自「支持向量机工具箱」· M 代码 · 共 44 行
M
44 行
function [x,y]=cliplin2(alpha,window)
% [x,y]=cliplin2(alpha,window)
%
% CLIPLIN2 clips the line going from pixel [0,0] to pixel on
% the border of the rectangle given by the argument window.
% The direction of the line is given by the argument alpha.
% This function returns coordinates of the mentioned pixel
% on the border.
%
% See also CLIPLIN1.
%
% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Written Vojtech Franc (diploma thesis) 12.10.1999
% Modifications
% 24. 6.00 V. Hlavac, comments polished.
% get window`s left side, right side, bottom...
minx=window(1);
maxx=window(2);
miny=window(3);
maxy=window(4);
if alpha(1) >= 0, ax = maxx; else ax = minx; end
if alpha(2) >= 0, ay = maxy; else ay = miny; end
if alpha(2) == 0,
x = ax;
else
x = alpha(1)*ay/alpha(2);
end
if alpha(1) == 0,
y = ay;
else
y = alpha(2)*ax/alpha(1);
end
if (x^2+ay^2) <= (ax^2+y^2),
y = ay;
else
x = ax;
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?