This commit is contained in:
leo 2022-03-25 12:05:00 +01:00
parent 9b30eb36c0
commit 426bcc8139
Signed by: leo
GPG Key ID: 0DD993BFB2B307DB

6
Car.py
View File

@ -1,5 +1,5 @@
import sumolib
from math import dist, ceil, sqrt, log
from math import dist, ceil, sqrt, log, cos, sin, atan2
from random import randint
from PySide6.QtGui import QPainter
from PySide6.QtCore import QPointF, Signal, QObject
@ -46,6 +46,7 @@ class Car():
self.startTime=float(startTime)
self.pos=[0,0]
self.dir=0
self.v=0
self.a=10
self.b=20
@ -213,6 +214,7 @@ class Car():
def draw(self,painter):
pt = QPointF(*self.pos)
painter.drawEllipse(pt,self.size,self.size)
painter.drawLine(self.pos[0], self.pos[1], self.pos[0]+5*cos(self.dir), self.pos[1]+5*sin(self.dir))
if self.vroom != 0:
painter.save()
@ -285,6 +287,8 @@ class Car():
lgt=self.v*dt
self.dir = atan2(self.laneShape[self.laneInd+1][1]-self.pos[1],self.laneShape[self.laneInd+1][0]-self.pos[0])
while(lgt>0):
endPos=self.laneShape[self.laneInd+1]
l=dist(self.pos,endPos)