Session2 30/9/22
This commit is contained in:
parent
b9471f779e
commit
2cbfccb8cc
@ -1,4 +1,5 @@
|
||||
from math import floor
|
||||
from math import floor, sqrt
|
||||
|
||||
|
||||
def transform_mp_to_abc(m, p):
|
||||
"""transforme une équation de la forme y = mx + p to ax + by = c
|
||||
@ -8,6 +9,7 @@ def transform_mp_to_abc(m, p):
|
||||
"""
|
||||
return -m, 1, p
|
||||
|
||||
|
||||
def transform_abc_to_mp(a, b, c):
|
||||
"""transforme une équation de la forme to ax + by = c to y = mx + p
|
||||
|
||||
@ -16,7 +18,8 @@ def transform_abc_to_mp(a, b, c):
|
||||
"""
|
||||
return -a/b, c
|
||||
|
||||
def droite(p1: tuple,p2: tuple) -> tuple:
|
||||
|
||||
def droite(p1: tuple, p2: tuple) -> tuple:
|
||||
"""retourne un 3-uple d'une droite selon ax+by=c
|
||||
|
||||
:p1: tuple du point 1
|
||||
@ -96,8 +99,6 @@ def droite_normale(d, p):
|
||||
return transform_mp_to_abc(-1/m, y-(-1/m)*x)
|
||||
|
||||
|
||||
|
||||
|
||||
def symetrie_orthogonale(d, p):
|
||||
""" retourne la symétrie orthogonale par le point p de la droite d
|
||||
:returns: symétrie orthogonale
|
||||
@ -105,14 +106,19 @@ def symetrie_orthogonale(d, p):
|
||||
"""
|
||||
a, b, c = d
|
||||
x, y = p
|
||||
ap, bp, cp = droite_normale(d,p) # perpendiculaire passant par le point
|
||||
xi, yi = intersection((a,b,c), (ap, bp, cp))
|
||||
ap, bp, cp = droite_normale(d, p) # perpendiculaire passant par le point
|
||||
xi, yi = intersection((a, b, c), (ap, bp, cp))
|
||||
return round((2*xi - x)*10)/10, round((2*yi - y)*10)/10
|
||||
|
||||
|
||||
def distance_droite_point(d, p):
|
||||
"""TODO: Docstring for distance_droite_point.
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
pass
|
||||
a, b, c = d
|
||||
x, y = p
|
||||
ap, bp, cp = droite_normale(d,p) # perpendiculaire passant par le point
|
||||
xi, yi = intersection((a,b,c), (ap, bp, cp))
|
||||
return sqrt((xi-x)**2 + (yi-y)**2)
|
||||
|
||||
|
@ -29,6 +29,7 @@ def tests():
|
||||
test(symetrie_orthogonale, (-0.5, 1, 1.0), (-2, 0), (-2.0, 0.0))
|
||||
test(symetrie_orthogonale, (-0.5, 1, 1.0), (3, 4), (4.2, 1.6))
|
||||
|
||||
test(distance_droite_point, (-0.5, 1, 1.0), (-2, 0), 1.3416407864998741)
|
||||
test(distance_droite_point, (-0.5, 1, 1.0), (-2, 0), 0.0)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user