radar.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:echolocation 作者: hgross 项目源码 文件源码
def _add_measurement(self, length, angle, added_time):
        """
        Adds a visualization for a measured distance to the scene
        :param length: length in cm
        :param angle: the angle
        """
        mx, my = self._get_middle()
        angle_rad = deg2rad(angle)
        ex, ey = mx + length * math.cos(angle_rad), my + length * math.sin(angle_rad)

        age = time.time() - added_time
        age = age if age < self.fade_out_time else self.fade_out_time
        alpha_channel_value = scale((0, self.fade_out_time), (255, 0), age)
        assert 0 <= alpha_channel_value <= 255

        brush_color = QColor(self.measured_distances_color)
        brush_color.setAlpha(alpha_channel_value)
        brush = QBrush(brush_color)
        tpen = QPen(brush_color)

        self.scene.addLine(mx, my, ex, ey, pen=tpen)
        self.scene.addEllipse(ex-self.dot_width/2, ey-self.dot_width/2, self.dot_width, self.dot_width, pen=tpen, brush=brush)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号