File size: 2,985 Bytes
01b44ac 0773e01 01b44ac 0773e01 765e25a 0773e01 765e25a 0773e01 765e25a 0773e01 765e25a 0773e01 765e25a 0773e01 765e25a 0773e01 765e25a 0773e01 765e25a 0773e01 01b44ac 0773e01 01b44ac 0773e01 01b44ac 0773e01 01b44ac 0773e01 01b44ac 765e25a |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import streamlit as st
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon, Circle
# Functions (including calculate_distance) are properly defined here
# Function to calculate the distance between two points
def calculate_distance(x1, y1, x2, y2):
return np.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
# Function to calculate angles using the Law of Cosines
def calculate_angle(a, b, c):
try:
angle = np.degrees(np.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c)))
except ValueError:
angle = 0 # Handle possible domain error in acos
return angle
# Additional helper functions remain here...
def main():
st.set_page_config(
page_title="Advanced Triangle Solver",
layout="wide",
initial_sidebar_state="expanded",
)
# Enhanced Aesthetic Style
st.markdown(
"""
<style>
body {
background-color: #f7f9fc;
color: #333333;
font-family: 'Open Sans', sans-serif;
}
.stTitle, .stHeader, .stSubheader {
color: #1a73e8;
font-weight: bold;
}
.stSidebar {
background-color: #f0f4f8;
color: #333333;
}
.stMarkdown {
font-size: 16px;
}
.stButton > button {
background-color: #1a73e8;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
.stButton > button:hover {
background-color: #155ab3;
}
</style>
""",
unsafe_allow_html=True,
)
st.title("πΊ Advanced Triangle Solver")
st.sidebar.header("π Input Coordinates")
# Collect user input
x1 = st.sidebar.number_input("X1", min_value=-100.0, max_value=100.0, step=0.1, format="%.2f")
y1 = st.sidebar.number_input("Y1", min_value=-100.0, max_value=100.0, step=0.1, format="%.2f")
x2 = st.sidebar.number_input("X2", min_value=-100.0, max_value=100.0, step=0.1, format="%.2f")
y2 = st.sidebar.number_input("Y2", min_value=-100.0, max_value=100.0, step=0.1, format="%.2f")
x3 = st.sidebar.number_input("X3", min_value=-100.0, max_value=100.0, step=0.1, format="%.2f")
y3 = st.sidebar.number_input("Y3", min_value=-100.0, max_value=100.0, step=0.1, format="%.2f")
if st.sidebar.button("Calculate π"):
# Logic to calculate triangle properties and display them
try:
a = calculate_distance(x2, y2, x3, y3)
b = calculate_distance(x1, y1, x3, y3)
c = calculate_distance(x1, y1, x2, y2)
# Add calculations for angles, area, perimeter, etc.
# Plot the triangle
st.success("Triangle successfully solved!")
except Exception as e:
st.error(f"An error occurred: {e}")
if __name__ == "__main__":
main()
|