Using Sin-1 or inverse sin in python

前端 未结 3 1498
忘掉有多难
忘掉有多难 2021-01-22 09:24

Here is my code:

# point of intersection between opposite and hypotenuse

x,y  =    pygame.mouse.get_pos()


# using formula for length of line

lenline1 = (x-x)         


        
相关标签:
3条回答
  • 2021-01-22 09:42

    Looks like you're trying to find the angle of the triangle (700,300), (x,300), (x,y). You're making it much more complicated than it needs to be. the length of the hypotenuse is math.hypot((700-x),(300-y)) and the angle is math.atan2((700-x), (300-y)).

    0 讨论(0)
  • 2021-01-22 09:49

    Don't bother with the k computation, its meaningless.

    j = math.asin(PQ)
    

    However, this only works for right-angled triangles and you have to appropriate side lengths in the right places. In general this will not work and you need to use the dot product method.

    0 讨论(0)
  • 2021-01-22 09:57

    To find the angle between two lines, use the following relation:

    cos(angle) = (l1 dot l2) / (|l1| |l2|)
    

    That is,

    dotproduct = l1x * l2x + l1y * l2y
    lenproduct = |l1| * |l2|
    angle = acos(dotproduct / lenproduct)
    

    where l1x, l1y are the x,y components of the line l1.

    0 讨论(0)
提交回复
热议问题