feat: add drawing trajectory

This commit is contained in:
2025-04-15 12:32:56 +03:00
parent a43e56cef3
commit e606b841a9
4 changed files with 77 additions and 19 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.venv
__pycache__

22
main.py
View File

@@ -7,6 +7,8 @@ import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from random_pilot import RandomPilot
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options)
@@ -29,26 +31,8 @@ action.click(driver.find_element(By.CLASS_NAME, '_key_satellite'))
action.pause(0.2)
action.perform()
class RandomPilot():
angle: float
def __init__(self):
self.dangle = 0
self.angle = random.random() * math.pi * 2
self.velocity = 50
def step(self) -> tuple[float, float]:
# Поворот угла траектории
self.dangle += (random.random() - 0.5) * 0.1
self.dangle = max(min(self.dangle, 0.2), -0.2)
self.angle += self.dangle
dx = math.cos(self.angle) * self.velocity
dy = math.sin(self.angle) * self.velocity
return dx, dy
randomPilot = RandomPilot()
randomPilot = RandomPilot(100)
while True:
# Сдвиг камеры

43
random_pilot.py Normal file
View File

@@ -0,0 +1,43 @@
import math
import random
# from scipy import
from matplotlib import pyplot as plt
class RandomPilot():
angle: float
def __init__(self, velocity: float = 1):
self.dangle = 0
self.angle = random.random() * math.pi * 2
self.velocity = velocity
def step(self) -> tuple[float, float]:
# Поворот угла траектории
self.dangle += (random.random() - 0.5) * 0.1
self.dangle = max(min(self.dangle, 0.2), -0.2)
self.angle += self.dangle
dx = math.cos(self.angle) * self.velocity
dy = math.sin(self.angle) * self.velocity
return dx, dy
def _test():
randomPilot = RandomPilot()
point = [0, 0]
iter_count = 500
points = [point.copy()]
for i in range(iter_count):
dx, dy = randomPilot.step()
point[0] += dx
point[1] += dy
points.append(point.copy())
print(*zip(*points))
plt.plot(*zip(*points), '--')
plt.show()
if __name__ == '__main__':
_test()

29
requirements.txt Normal file
View File

@@ -0,0 +1,29 @@
attrs==25.3.0
certifi==2025.1.31
cffi==1.17.1
contourpy==1.3.1
cycler==0.12.1
fonttools==4.57.0
h11==0.14.0
idna==3.10
kiwisolver==1.4.8
matplotlib==3.10.1
numpy==2.2.4
outcome==1.3.0.post0
packaging==24.2
pillow==11.2.1
pycparser==2.22
pyparsing==3.2.3
PySocks==1.7.1
python-dateutil==2.9.0.post0
scipy==1.15.2
selenium==4.31.0
six==1.17.0
sniffio==1.3.1
sortedcontainers==2.4.0
trio==0.29.0
trio-websocket==0.12.2
typing_extensions==4.13.2
urllib3==2.4.0
websocket-client==1.8.0
wsproto==1.2.0