Discuss / Python / 请问廖老师,这里你写错了吗?

请问廖老师,这里你写错了吗?

Topic source

kimkim旺

#1 Created at ... [Delete] [Delete and Lock User]

Q1:

import math

def move(x, y, step, angle=0):
    nx = x + step * math.cos(angle)
    ny = y - step * math.sin(angle)
    return nx, ny

ny = y - step * math.sin (angle) 这里应该是 y + step * math.sin (angle) 是吗?

ny 我的理解应该是位移后的 y 坐标,我计算了一下,无论哪个象限也都是相加,怎么是相减呢?

Q2:

然后,我们就可以同时获得返回值:

>>> x, y = move(100, 100, 60, math.pi / 6)
>>> print(x, y)
151.96152422706632 70.0

请问 x, y = move(100, 100, 60, math.pi / 6)

是定义 x,y 的参数吗?能解释一下这些参数的含义吗?谢谢!

哇,楼主和我想问的问题一模一样


  • 1

Reply