Skip to content

Commit 8601406

Browse files
committed
Calculation of angular cooridor which updates to user input and renders representation on maze graphicimplemented.
1 parent 7362197 commit 8601406

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

SearchStrategyAnalysis/Pathfinder.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,29 @@ def buildGUI(self, root): # Called in the __init__ to build the GUI window
611611
self.start = canvas.create_oval(195, 195 + scale * radius, 205, 205 + scale * radius, fill="green", width=1)
612612
self.goal = canvas.create_oval(goalLBorder, goalTopBorder, goalRBorder, goalBottomBorder, fill="red", width=1)
613613

614+
615+
# calculation of angular cooridor, updates to user input and renders blue lines on user interface
616+
# to represent outer bounds of cooridor
617+
rightCorridorSideAngle = math.radians(float(corridorWidthStringVar.get())/2 + math.degrees(math.atan((float(goalX))/(float(goalY) + radius))))
618+
rightCorridorLeftDiameterChordSection = radius + radius* math.tan(rightCorridorSideAngle)
619+
rightCorridorRightDiameterChordSection = radius - radius* math.tan(rightCorridorSideAngle)
620+
rightCorridorBottomChordSection = radius / math.cos(rightCorridorSideAngle)
621+
rightCorridorTopChordSection = (rightCorridorLeftDiameterChordSection*rightCorridorRightDiameterChordSection)/rightCorridorBottomChordSection
622+
rightCorridorOnCircleX = radius*math.tan(rightCorridorSideAngle) + rightCorridorTopChordSection*math.sin(rightCorridorSideAngle)
623+
rightCorridorOnCircleY = rightCorridorTopChordSection * math.cos(rightCorridorSideAngle)
624+
self.rightAngularCooridorLine = canvas.create_line(200, 200 + scale * radius, 200 + scale*(rightCorridorOnCircleX), 200 - (scale * rightCorridorOnCircleY), fill = "blue", width = 2)
625+
626+
leftCorridorSideAngle = rightCorridorSideAngle - math.radians(float(corridorWidthStringVar.get()))
627+
leftCorridorLeftDiameterChordSection = radius + radius* math.tan(leftCorridorSideAngle)
628+
leftCorridorRightDiameterChordSection = radius - radius* math.tan(leftCorridorSideAngle)
629+
leftCorridorBottomChordSection = radius / math.cos(leftCorridorSideAngle)
630+
leftCorridorTopChordSection = (leftCorridorLeftDiameterChordSection*leftCorridorRightDiameterChordSection)/leftCorridorBottomChordSection
631+
leftCorridorOnCircleX = radius*math.tan(leftCorridorSideAngle) + leftCorridorTopChordSection*math.sin(leftCorridorSideAngle)
632+
leftCorridorOnCircleY = leftCorridorTopChordSection * math.cos(leftCorridorSideAngle)
633+
self.leftAngularCooridorLine = canvas.create_line(200, 200 + scale * radius, 200 + scale*(leftCorridorOnCircleX), 200 - (scale * leftCorridorOnCircleY),fill = "blue", width = 2)
634+
635+
636+
614637
# draw all rois
615638
for aTuple in rois:
616639
roiX, roiY = aTuple[0].split(",")
@@ -688,6 +711,30 @@ def redraw(*args):
688711
self.start = canvas.create_oval(195, 195 + scale*radius, 205, 205 + scale*radius, fill="green", width=1)
689712
self.goal = canvas.create_oval(goalLBorder, goalTopBorder, goalRBorder, goalBottomBorder, fill="red", width=1)
690713

714+
715+
# calculation of angular cooridor, updates to user input and renders blue lines on user interface
716+
# to represent outer bounds of cooridor
717+
rightCorridorSideAngle = math.radians(float(corridorWidthStringVar.get())/2 + math.degrees(math.atan((float(goalX))/(float(goalY) + radius))))
718+
rightCorridorLeftDiameterChordSection = radius + radius* math.tan(rightCorridorSideAngle)
719+
rightCorridorRightDiameterChordSection = radius - radius* math.tan(rightCorridorSideAngle)
720+
rightCorridorBottomChordSection = radius / math.cos(rightCorridorSideAngle)
721+
rightCorridorTopChordSection = (rightCorridorLeftDiameterChordSection*rightCorridorRightDiameterChordSection)/rightCorridorBottomChordSection
722+
rightCorridorOnCircleX = radius*math.tan(rightCorridorSideAngle) + rightCorridorTopChordSection*math.sin(rightCorridorSideAngle)
723+
rightCorridorOnCircleY = rightCorridorTopChordSection * math.cos(rightCorridorSideAngle)
724+
self.rightAngularCooridorLine = canvas.create_line(200, 200 + scale * radius, 200 + scale*(rightCorridorOnCircleX), 200 - (scale * rightCorridorOnCircleY), fill = "blue", width = 2)
725+
726+
727+
leftCorridorSideAngle = rightCorridorSideAngle - math.radians(float(corridorWidthStringVar.get()))
728+
leftCorridorLeftDiameterChordSection = radius + radius* math.tan(leftCorridorSideAngle)
729+
leftCorridorRightDiameterChordSection = radius - radius* math.tan(leftCorridorSideAngle)
730+
leftCorridorBottomChordSection = radius / math.cos(leftCorridorSideAngle)
731+
leftCorridorTopChordSection = (leftCorridorLeftDiameterChordSection*leftCorridorRightDiameterChordSection)/leftCorridorBottomChordSection
732+
leftCorridorOnCircleX = radius*math.tan(leftCorridorSideAngle) + leftCorridorTopChordSection*math.sin(leftCorridorSideAngle)
733+
leftCorridorOnCircleY = leftCorridorTopChordSection * math.cos(leftCorridorSideAngle)
734+
self.leftAngularCooridorLine = canvas.create_line(200, 200 + scale * radius, 200 + scale*(leftCorridorOnCircleX), 200 - (scale * leftCorridorOnCircleY), fill = "blue", width = 2)
735+
736+
737+
691738
# draw all rois
692739
for aTuple in rois:
693740
roiX, roiY = aTuple[0].split(",")

0 commit comments

Comments
 (0)