Compare commits
No commits in common. "2cbfccb8ccb7de9ee725ea42c19a09fa37c0215d" and "9386728e964d1ebd4ce7e64ea8671de1f730d9b2" have entirely different histories.
2cbfccb8cc
...
9386728e96
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
__pycache__/
|
BIN
29sept/ex2-1/__pycache__/droite.cpython-310.pyc
Normal file
BIN
29sept/ex2-1/__pycache__/droite.cpython-310.pyc
Normal file
Binary file not shown.
@ -1,25 +1,4 @@
|
||||
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
|
||||
|
||||
:returns: 3-uple of a, b, c
|
||||
|
||||
"""
|
||||
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
|
||||
|
||||
:returns: tuple of m, x
|
||||
|
||||
"""
|
||||
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
|
||||
@ -85,40 +64,27 @@ def intersection(d1, d2):
|
||||
|
||||
|
||||
def droite_normale(d, p):
|
||||
"""trouve la normale dune droite passant par un point.
|
||||
"""TODO: trouve la normale dune droite passant par un point.
|
||||
|
||||
:d: droite
|
||||
:p: point
|
||||
:returns: retourne la normale de la droite passant par le point
|
||||
|
||||
"""
|
||||
a, b, c = d
|
||||
x, y = p
|
||||
|
||||
m, p = transform_abc_to_mp(a, b, c)
|
||||
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
|
||||
"""TODO: Docstring for symetrie_orthogonale(d, p.
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
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 round((2*xi - x)*10)/10, round((2*yi - y)*10)/10
|
||||
|
||||
pass
|
||||
|
||||
def distance_droite_point(d, p):
|
||||
"""TODO: Docstring for distance_droite_point.
|
||||
:returns: TODO
|
||||
|
||||
"""
|
||||
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)
|
||||
pass
|
||||
|
||||
|
@ -27,9 +27,8 @@ def tests():
|
||||
test(droite_normale, (-0.5, 1, 1.0), (3, 4), (2.0, 1, 10.0))
|
||||
|
||||
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(symetrie_orthogonale, (-0.5, 1, 1.0), (3, 4), (2.0, 1, 10.0))
|
||||
|
||||
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