MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / cut

Method cut

PythonAPI/examples/gamma_crowd.py:539–559  ·  view source on GitHub ↗
(self, sidewalk, position)

Source from the content-addressed store, hash-verified

537 return True
538
539 def cut(self, sidewalk, position):
540 cut_index = 0
541 min_offset = None
542 min_offset_index = None
543 for i in range(int(len(self.route_points) / 2)):
544 route_point = self.route_points[i]
545 offset = position - sidewalk.get_route_point_position(route_point)
546 offset = offset.length()
547 if min_offset is None or offset < min_offset:
548 min_offset = offset
549 min_offset_index = i
550 if offset <= 1.0:
551 cut_index = i + 1
552
553 # Invalid path because too far away.
554 if min_offset > 1.0:
555 self.route_points = self.route_points[min_offset_index:]
556 self.route_orientations = self.route_orientations[min_offset_index:]
557 else:
558 self.route_points = self.route_points[cut_index:]
559 self.route_orientations = self.route_orientations[cut_index:]
560
561 def get_position(self, sidewalk, index=0):
562 return sidewalk.get_route_point_position(self.route_points[index])

Callers 1

do_gammaFunction · 0.45

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected