Compare commits
3 Commits
9386728e96
...
2cbfccb8cc
Author | SHA1 | Date | |
---|---|---|---|
2cbfccb8cc | |||
b9471f779e | |||
a5221b52a5 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
__pycache__/
|
Binary file not shown.
@ -1,3 +1,24 @@
|
|||||||
|
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
|
"""retourne un 3-uple d'une droite selon ax+by=c
|
||||||
|
|
||||||
@ -64,27 +85,40 @@ def intersection(d1, d2):
|
|||||||
|
|
||||||
|
|
||||||
def droite_normale(d, p):
|
def droite_normale(d, p):
|
||||||
"""TODO: trouve la normale dune droite passant par un point.
|
"""trouve la normale dune droite passant par un point.
|
||||||
|
|
||||||
:d: droite
|
:d: droite
|
||||||
:p: point
|
:p: point
|
||||||
:returns: retourne la normale de la droite passant par le 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):
|
def symetrie_orthogonale(d, p):
|
||||||
"""TODO: Docstring for symetrie_orthogonale(d, p.
|
""" retourne la symétrie orthogonale par le point p de la droite d
|
||||||
:returns: TODO
|
:returns: symétrie orthogonale
|
||||||
|
|
||||||
"""
|
"""
|
||||||
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 round((2*xi - x)*10)/10, round((2*yi - y)*10)/10
|
||||||
|
|
||||||
|
|
||||||
def distance_droite_point(d, p):
|
def distance_droite_point(d, p):
|
||||||
"""TODO: Docstring for distance_droite_point.
|
"""TODO: Docstring for distance_droite_point.
|
||||||
:returns: TODO
|
: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)
|
||||||
|
|
||||||
|
@ -27,8 +27,9 @@ def tests():
|
|||||||
test(droite_normale, (-0.5, 1, 1.0), (3, 4), (2.0, 1, 10.0))
|
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), (-2, 0), (-2.0, 0.0))
|
||||||
test(symetrie_orthogonale, (-0.5, 1, 1.0), (3, 4), (2.0, 1, 10.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)
|
test(distance_droite_point, (-0.5, 1, 1.0), (-2, 0), 0.0)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user