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

Method horizontal_angle

src/__init__.py:14836–14853  ·  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

14834
14835 @staticmethod
14836 def horizontal_angle(C, P):
14837 """Return the angle to the horizontal for the connection from C to P.
14838 This uses the arcus sine function and resolves its inherent ambiguity by
14839 looking up in which quadrant vector S = P - C is located.
14840 """
14841 S = Point(P - C).unit # unit vector 'C' -> 'P'
14842 alfa = math.asin(abs(S.y)) # absolute angle from horizontal
14843 if S.x < 0: # make arcsin result unique
14844 if S.y <= 0: # bottom-left
14845 alfa = -(math.pi - alfa)
14846 else: # top-left
14847 alfa = math.pi - alfa
14848 else:
14849 if S.y >= 0: # top-right
14850 pass
14851 else: # bottom-right
14852 alfa = -alfa
14853 return alfa
14854
14855 def __init__(self, page: Page):
14856 CheckParent(page)

Callers 1

draw_sectorMethod · 0.95

Calls 1

PointClass · 0.85

Tested by

no test coverage detected