📄 arrow.m
字号:
function arrow(point1,point2,S,rlength,rwidth)
% The function:
%
% arrow(point1,point2,S,rlength,rwidth)
%
% draws an arrow from point <point1> to point <point2>
% in the 2-dimensional space.
% Optional arg <S> is like in plot(X,Y,S);
% default value is '-'.
% Optional arg <rlength> is the relative length of the
% pointing end; default value is 0.3.
% Optional arg <rwidth> is the relative width of the
% pointing end; default value is 0.2.
% args
if nargin<2, error('not enough args'); end;
if nargin<3, S = '-'; end;
if nargin<4, rlength = 0.3; end;
if nargin<5, rwidth = 0.2; end;
% unit arrow
arrowx = [0,1,1.0-rlength,1,1.0-rlength];
arrowy = [0,0,+0.5*rwidth,0,-0.5*rwidth];
% vector
vector = point2 - point1;
% dilation, rotation & plot
if length(vector)==2,
drot = [[+vector(1),-vector(2)];
[+vector(2),+vector(1)]];
arrowxy = drot*[arrowx;arrowy];
plot(point1(1)+arrowxy(1,:),point1(2)+arrowxy(2,:),S);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -