-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbox_from_corners.py
More file actions
executable file
·29 lines (25 loc) · 970 Bytes
/
box_from_corners.py
File metadata and controls
executable file
·29 lines (25 loc) · 970 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
26
27
28
29
import numpy as np
def box_from_corners(xs,ys):
"""
% (C) Nick Holschuh - Amherst College -- 2022 ([email protected])
%
% This function takes x and y edge values for a rectangle, and produces a
% 5x2 array of corner points that trace out the rectangle (for use in plotting)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The inputs are:
%
% xs - 2 value array contaiining the x edges of the rectangle
% ys - 2 value array contaiining the y edges of the rectangle
%
%%%%%%%%%%%%%%%
% The outputs are:
%
% box -- the 5x2 array containing the corner points for the rectangle
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"""
x_array = np.array([xs[0],xs[1],xs[1],xs[0],xs[0]])
y_array = np.array([ys[1],ys[1],ys[0],ys[0],ys[1]])
box = np.stack([x_array,y_array]).T
return box