import numpy as np
# Choix du point d'appui fixe
reponse = input("Est-ce que l'appui est fixe en A ? (oui/non): ").lower()
cas = "2" if reponse == "oui" else "1"
# Entrée des données
L = float(input("Longueur totale de la poutre L (m): "))
a = float(input("Position du point de moment a (m): "))
# Forces ponctuelles
F1 = float(input("Force F1 (N): "))
F2 = float(input("Force F2 (N): "))
F3 = float(input("Force F3 (N): "))
xF1 = float(input("Position xF1 (m): "))
xF2 = float(input("Position xF2 (m): "))
xF3 = float(input("Position xF3 (m): "))
# Angles (convertis en radians)
alpha1 = [Link](float(input("Angle alpha1 : ")))
alpha2 = [Link](float(input("Angle alpha2 : ")))
alpha3 = [Link](float(input("Angle alpha3 : ")))
F1y = F1 * [Link](alpha1)
F2y = F2 * [Link](alpha2)
F3y = F3 * [Link](alpha3)
F1x = F1 * [Link](alpha1)
F2x = F2 * [Link](alpha2)
F3x = F3 * [Link](alpha3)
# Charges réparties
q1 = float(input("Valeur de q1 (N/m): "))
xgq1 = float(input("Position du centre de q1 (m): "))
q2 = float(input("Valeur de q2 (N/m): "))
xgq2 = float(input("Position du centre de q2 (m): "))
q3 = float(input("Valeur de q3 (N/m): "))
xgq3 = float(input("Position du centre de q3 (m): "))
Fq1 = q1 * 1
Fq2 = q2 * 1
Fq3 = q3 * 1
# Moments
MF = F1y * (a - xF1) - F2y * (xF2 - a) - F3y * (xF3 - a)
Mq = q1 * (xgq1 - a) + q2 * (xgq2 - a) + q3 * (xgq3 - a)
# Système matriciel
A = [Link]([
[1, 1],
[a, -(L - a)]
])
B = [Link]([
F1y + F2y + F3y + Fq1 + Fq2 + Fq3,
MF + Mq
])
sol = [Link](A, B)
RAy, RBy = sol
# Résultats
print("\n=== Résultats ===")
if cas == "1":
RBx = F1x + F2x + F3x
print(f"RBx = {RBx:.2f} N")
print(f"RBy = {RBy:.2f} N")
print(f"RAy = {RAy:.2f} N")
else:
RAx = F1x + F2x + F3x
print(f"RAx = {RAx:.2f} N")
print(f"RAy = {RAy:.2f} N")
print(f"RBy = {RBy:.2f} N")