<p>所以我用python编写了一个程序,我有一些点,在一个按键上,我需要让它们沿着轴旋转,所以按x,它将围绕x轴旋转,按y,表示y,按z,表示z</p>
<p>我很确定我的代码布局是正确的
首先我定义我的旋转值</p>
<pre><code>x_rot = 1
y_rot = 1
z_rot = 1
</code></pre>
<p>接下来我设置我的数学值:</p>
<pre><code> #setup angles for rotation
angle = 1
rad = angle * math.pi / 180
cose = math.cos(rad)
sine = math.sin(rad)
</code></pre>
<p>然后,我按照以下格式在名为Xs、Ys和Zs的列表中设置我的x y和z点:</p>
<pre><code> Xs=(12.0, 25.0, 10.0, 22.0)
Ys=(2.0, 15.0, 12.0, 27.0)
Zs=(21.0, 23.0, 1.0, 12.0)
</code></pre>
<p>下一步,我设置我的按键,使我的坐标值乘以一个旋转矩阵,这样当我按下键盘上的x按钮时,我的点就围绕x轴旋转。</p>
<pre><code>done = False
while done == False:
# ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
for event in pygame.event.get(): # User did something
if event.type == pygame.QUIT: # If user clicked close
done = True # Flag that we are done so we exit this loop
# User pressed down on a key
elif event.type == pygame.KEYDOWN | event.type == pygame.KEYUP:
if event.key == pygame.K_x:
y_rot == Ys*cose(angle)-Zs*(angle)
z_rot == Ys*sine(angle)-Zs*cose(angle)
x_rot == Xs
</code></pre>
<p>然后我运行我的代码,它工作正常,直到我按x按钮旋转它。当我按下按钮时,我会说一个错误</p>
<pre><code>typeerror 'float' object is not callable
</code></pre>
<p>它引用了这一行</p>
<pre><code>y_rot == Ys*cose(angle)-Zs*(angle)
</code></pre>
<p>我有一种感觉,这是一个简单的解决办法,但我只是想不出它可能是什么。</p>