-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetTriangle.m
More file actions
25 lines (25 loc) · 803 Bytes
/
getTriangle.m
File metadata and controls
25 lines (25 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function pointList = getTriangle(x, y, a, h, pointing)
switch pointing
case 'UpArrow' % upwards
pointList = round([x, y - h;
x - a/2, y;
x + a/2, y]);
case 'DownArrow' % downwards
pointList = round([x, y + h;
x - a/2, y;
x + a/2, y]);
case 'RightArrow' % right
pointList = round([x + h, y;
x, y - a/2;
x, y + a/2]);
case 'LeftArrow' % left
pointList = round([x - h, y;
x, y + a/2;
x, y - a/2]);
end
% shift the triangle center of mass
% to the center of the screen
center = mean(pointList);
d = [x, y] - center;
pointList = pointList + d;
end