MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / horizontal_angle

Method horizontal_angle

src_classic/utils.py:3077–3094  ·  view source on GitHub ↗

Return the angle to the horizontal for the connection from C to P. This uses the arcus sine function and resolves its inherent ambiguity by looking up in which quadrant vector S = P - C is located.

(C, P)

Source from the content-addressed store, hash-verified

3075
3076 @staticmethod
3077 def horizontal_angle(C, P):
3078 """Return the angle to the horizontal for the connection from C to P.
3079 This uses the arcus sine function and resolves its inherent ambiguity by
3080 looking up in which quadrant vector S = P - C is located.
3081 """
3082 S = Point(P - C).unit # unit vector 'C' -> 'P'
3083 alfa = math.asin(abs(S.y)) # absolute angle from horizontal
3084 if S.x < 0: # make arcsin result unique
3085 if S.y <= 0: # bottom-left
3086 alfa = -(math.pi - alfa)
3087 else: # top-left
3088 alfa = math.pi - alfa
3089 else:
3090 if S.y >= 0: # top-right
3091 pass
3092 else: # bottom-right
3093 alfa = -alfa
3094 return alfa
3095
3096 def __init__(self, page: Page):
3097 CheckParent(page)

Callers 1

draw_sectorMethod · 0.95

Calls 1

PointClass · 0.85

Tested by

no test coverage detected