ptsinterectionplandroite.py

Created by gregoirehulin06

Created on December 14, 2023

1.08 KB


def produit_scalaire(v1, v2):
    return sum(a*b for a, b in zip(v1, v2))

def trouver_intersection(plan, droite):
    a, b, c, d = plan
    x0, y0, z0, ad, bd, cd = droite
    vn = (a, b, c)  # Vecteur normal
    vd = (ad, bd, cd)  # Vecteur directeur

    if produit_scalaire(vn, vd) == 0:
        return "Pas d'intersection (droite parallèle)"

    t = (d - a*x0 - b*y0 - c*z0) / produit_scalaire(vn, vd)
    x = x0 + ad * t
    y = y0 + bd * t
    z = z0 + cd * t
    return (x, y, z)

# Entrée des paramètres du plan
print("Entrez les coefficients du plan :")
a = float(input("a = "))
b = float(input("b = "))
c = float(input("c = "))
d = float(input("d = "))
plan = (a, b, c, d)

# Entrée des paramètres de la droite
print("Entrez les paramètres de la droite :")
x0 = float(input("x0 = "))
y0 = float(input("y0 = "))
z0 = float(input("z0 = "))
ad = float(input("ad = "))
bd = float(input("bd = "))
cd = float(input("cd = "))
droite = (x0, y0, z0, ad, bd, cd)

# Affichage du point d'intersection
print("Point d'intersection :", trouver_intersection(plan, droite))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.