% This routine helps to draw filled arrows (technically, to be implemented 
% with Matlab's "patch" command) in the plane. The center of the arrow
% patch is in the origin. 
%
% Arguments:
% alen   number in [0,1], gives length of the desired arrow relative
%       to the distance between start and end points
% adir   angle with respect to x-axis (in radians)
%
% Returns:
% x     vector of x-coordinates
% y     vector of y-coordinates
%
% Example:
% [x,y] = arrowpoints(10);
% patch(x,y,[1 0 0])
%
% Samuli Siltanen February 2025

function [x,y] = arrow_patch_points(alen,adir)



% Initialize vectors of x and y coordinates for an arrow of length 1 
% pointing to the right
x = [-alen/2, alen/6, alen/6, alen/1.3,alen/6,alen/6,-alen/2];
y = [-alen/5,-alen/5,-alen/2,      0,alen/2,alen/5, alen/5];

% Rotation matrix
A = [[cos(adir) -sin(adir)];[sin(adir) cos(adir)]];

% Perform rotation
tmp = A*[x;y];
x = tmp(1,:);
y = tmp(2,:);




