在pybox2d manual它規定了以下內容:如何保持pybox2d中的身體角度在-pi和pi之間?
pybox2d uses radians for angles. The body rotation is stored in radians and may grow unbounded. Consider normalizing the angle of your bodies if the magnitude of the angle becomes too large (use b2Body.SetAngle).
然而,當我試圖實現的東西「正常化」我得到以下錯誤的角度:
AttributeError: 'b2Body' object has no attribute 'SetAngle'
代碼片段:
def update_outputs(self):
# This is necessary to prevent the angle
# from getting too large or small
self.body.SetAngle(self.body.angle % 2*pi)
爲什麼這個問題標記C++?它與這種語言有關嗎? –
pybox2d實際上是一個名爲Box2D的C++庫的綁定。 – Bill
我使用pybox2d 2.3.1版本,但2.1.0手冊,所以我不知道它是否過時。 – Bill