% o : original vector
% b : base line
% n : nomal line
% theta : between angle
clc; clear; close all;
%% original line (input set)
% original vector set
o.x = [-1 2];
o.y = [1 -2];
o.u = [3 2];
o.v = [-1 -4];
o.a = atan2d(o.u,o.v);
o.mag = sqrt(o.u.^2+o.v.^2);
% tracking line set
b.u = -5;
b.v = 5;
b.a = atan2d(b.v,b.u);
%% nomal line
if b.a > 0
n.a = b.a-90;
else
n.a = b.a+90;
end
% angle between
theta = (n.a-o.a);
n.mag = o.mag.*cosd(theta);
n.u = n.mag.*sind(n.a);
n.v = n.mag*cosd(n.a);
%% figure
figure('visible','on')
set(gca,'fontname','Arial','fontweight','bold','fontsize',15,'Box','on');
set(gcf,'color','w','Units','Normalized','OuterPosition',[1.2 0.2 .3 .5]);
hold on;
% plot
plot([-10*cosd(90-b.a) 10*cosd(90-b.a)],[-10*sind(90-b.a) 10*sind(90-b.a)],'k')
quiver(o.x,o.y,n.v,n.u)
'matlab' 카테고리의 다른 글
파일 존재 여부 확인(exist, isfile) (0) | 2023.01.06 |
---|---|
무한루프를 n초마다 실행 (0) | 2022.12.23 |
동일한 패턴으로 반복되는 행렬 생성 (0) | 2022.12.20 |
2차원 행렬 1차원 단일 행으로 변경 (0) | 2022.12.13 |
datetick을 이용한 x축의 날짜 간격 조절 (0) | 2022.12.10 |