-1

可能重复:
在 python 中使用 Sin-1 或 inverse sin

这是我的代码:

# point of intersection between opposite and hypotenuse

x,y  =    pygame.mouse.get_pos()


# using formula for length of line

lenline1 = (x-x)**2 + (300-y)**2
lenline2 = (x-700)**2 + (y-300)**2

opposite = math.sqrt(lenline1)

adjacent = math.sqrt(lenline2)

# Converting length of lines to angle

PQ = opposite/adjacent
k = math.sin(PQ)
j = math.asin(k)

print(j)

我没有得到我预期的结果,虽然在搞砸之后我接近了,但它不太正确。有人可以告诉我我做错了什么。我有两条线:相反和相邻我希望使用 sin 的倒数来获得角度。我究竟做错了什么。我只是一个初学者,所以不要提供太详细的信息。我无法想象这很难做到。

谢谢。

我试图得到斜边和相邻交汇的角度!

4

1 回答 1

0

^在 Python 中表示排他或,而不是求幂。如果要取幂,请使用**运算符。

于 2012-09-15T09:17:28.817 回答