📄 exp_clipline.m
字号:
% CLIPLINE clips line into given window.
%
% Synopsis:
% [x1,y1,x2,y2,inside] = clipline(W,b,window)
%
% Description:
% This function returns 2d points (x1,y1) and (x2,y2)
% of a line segment given by line
% W'*x + b = 0
%
% clipped to the given window.
%
% Input:
% W [2x1] Normal of line.
% b [1x1] Line threshold.
% window [4x1] Contains [left right top bottom].
%
% Output:
% x1 [1x1], y1 [1x1] The first point of line segment.
% x2 [1x1], y2 [1x1] The second point of line segment.
% inside [1x1] 1 if line W'*x+b=0 intersects the window.
%
% Example:
% figure; hold on;
% axis([-1 1 -1 1]);
% window = 0.5*axis;
% [x1,y1,x2,y2]=clipline([-1;1],0,window);
% plot([x1 x2],[y1 y2]);
figure; hold on;
axis([-1 1 -1 1]);
window = 0.5*axis;
[x1,y1,x2,y2]=clipline([-1;1],0,window);
plot([x1 x2],[y1 y2]);
% [x1,y1,x2,y2]=clipline([-1;1],-0.5,window);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -