Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Reto mouredev#42 - Python
Browse files Browse the repository at this point in the history
  • Loading branch information
alberba committed Dec 22, 2023
1 parent 5cbac74 commit 468b893
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Retos/Reto #42 - PUNTO DE ENCUENTRO [Difícil]/python/alberba.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
def colision(posicionA, posicionB, velocidadA, velocidadB):

xA, yA = posicionA
xB, yB = posicionB
vxA, vyA = velocidadA
vxB, vyB = velocidadB

if vxA - vxB == 0:
if xA == xB:
tx = 0
else:
return "Los objetos no se encontrarán."
else:
tx = (xB - xA) / (vxA - vxB)

if vyA - vyB == 0:
if yA == yB:
ty = 0
else:
return "Los objetos no se encontrarán."
else:
ty = (yB - yA) / (vyA - vyB)

if tx == ty:
t = tx
x = xA + vxA * tx
y = yA + vyA * ty
return f"Los objetos colisionan en el punto ({x}, {y}) en un tiempo {t}."
else:
return "Los objetos no se encontrarán."

print(colision((0, 0), (1, 1), (1, 1), (0, 0)))

0 comments on commit 468b893

Please sign in to comment.