Utility module¶
-
Utility.
center
(win)[source]¶ Centers the window by checking screen width then setting the window’s geometry
- Parameters
win (Tkinter.Tk) – root window
-
Utility.
find_intersecting_point
(line1, line2)[source]¶ Finds the intersecting points between two line
Currently buggy for near zero slopes - need some work on re-writing this algo.
Probably need to move from algebra to calculus/vectors after more reading.
How it’s currently calculating:
\(y = m_1x+b_1\)
\(y = m_2x+b_2\)
\(m_1x+b_1 = m_2x+b_2\)
\(x_\text{intersect} = \frac{b_2-b_1}{m_1-m_2}\)
\(y_\text{intersect} = m_1(x_\text{intersect})+b_1\)
- Parameters
line1 (Tuple) – A tuple of the form (slope, intercept, vertical, (endpoint_x, endpoint_y))
line2 (Tuple) – A tuple of the form (slope, intercept, vertical, (endpoint_x, endpoint_y))
- Returns
A tuple of (x,y) corresponding to the intersecting point
- Return type
Tuple
-
Utility.
get_line
(x1, y1, x2, y2)[source]¶ Finds slope and intercept of a line given two points
- Parameters
x1 – the old x, old displacement
y1 – the old y, old displacement
x2 – the target x, new displacement
y2 – the target y, new displacement
- Returns
A tuple (slope, intercept, vertical, endpoint), where vertical is False if not vertical and endpoint is x2, y2
- Return type
Tuple