|
import streamlit as st |
|
def set_background_video(): |
|
video_path = 'numbers moving background.mp4' |
|
with open(video_path, 'rb') as video_file: |
|
video_bytes = video_file.read() |
|
video_base64 = base64.b64encode(video_bytes).decode('utf-8') |
|
|
|
|
|
video_html = f""" |
|
<video |
|
style="position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%; width: auto; height: auto; z-index: -1;" |
|
preload="auto" |
|
autoplay |
|
loop |
|
muted |
|
> |
|
<source src="data:video/mp4;base64,{video_base64}" type="video/mp4"> |
|
Your browser does not support the video tag. |
|
</video> |
|
""" |
|
st.markdown(video_html, unsafe_allow_html=True) |
|
|
|
|
|
def calculate_distance(x1, y1, x2, y2): |
|
return np.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) |
|
|
|
def calculate_angle(a, b, c): |
|
try: |
|
angle = np.degrees(np.arccos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c))) |
|
except ValueError: |
|
angle = 0 |
|
return angle |
|
|
|
|
|
|
|
|
|
|
|
def plot_triangle(x1, y1, x2, y2, x3, y3, I_x, I_y, U_x, U_y, G_x, G_y, midpoints, a, b, c): |
|
|
|
|
|
def is_valid_triangle(a, b, c): |
|
return a + b > c and b + c > a and c + a > b |
|
|
|
|
|
def main(): |
|
st.title("Advanced Triangle Solver") |
|
|
|
st.sidebar.header("Enter the coordinates of the three points:") |
|
x1 = st.sidebar.number_input("X1", min_value=-100.0, max_value=100.0, step=0.1, format="%.3f") |
|
y1 = st.sidebar.number_input("Y1", min_value=-100.0, max_value=100.0, step=0.1, format="%.3f") |
|
x2 = st.sidebar.number_input("X2", min_value=-100.0, max_value=100.0, step=0.1, format="%.3f") |
|
y2 = st.sidebar.number_input("Y2", min_value=-100.0, max_value=100.0, step=0.1, format="%.3f") |
|
x3 = st.sidebar.number_input("X3", min_value=-100.0, max_value=100.0, step=0.1, format="%.3f") |
|
y3 = st.sidebar.number_input("Y3", min_value=-100.0, max_value=100.0, step=0.1, format="%.3f") |
|
|
|
if st.sidebar.button("Calculate"): |
|
a = calculate_distance(x2, y2, x3, y3) |
|
b = calculate_distance(x1, y1, x3, y3) |
|
c = calculate_distance(x1, y1, x2, y2) |
|
|
|
if not is_valid_triangle(a, b, c): |
|
st.error("The entered points do not form a valid triangle.") |
|
return |
|
|
|
A = calculate_angle(a, b, c) |
|
B = calculate_angle(b, a, c) |
|
C = calculate_angle(c, a, b) |
|
|
|
if abs(A + B + C - 180) > 1e-2: |
|
st.error("The sum of the angles is not 180 degrees.") |
|
return |
|
|
|
|
|
area = calculate_area(a, b, c) |
|
perimeter = calculate_perimeter(a, b, c) |
|
radius_in = calculate_radius_inscribed_circle(a, b, c) |
|
radius_circum = calculate_radius_circumscribed_circle(a, b, c) |
|
G_x, G_y = calculate_centroid(x1, y1, x2, y2, x3, y3) |
|
I_x, I_y = calculate_incenter(x1, y1, x2, y2, x3, y3, a, b, c) |
|
U_x, U_y = calculate_circumcenter(x1, y1, x2, y2, x3, y3, a, b, c) |
|
midpoints = calculate_midpoints(x1, y1, x2, y2, x3, y3) |
|
|
|
|
|
|
|
|
|
|
|
plot_triangle(x1, y1, x2, y2, x3, y3, I_x, I_y, U_x, U_y, G_x, G_y, midpoints, a, b, c) |
|
|
|
if __name__ == "__main__": |
|
main() |