计算svg path 中的A (elliptical arc command)(此处假定是圆弧, 即 rx=ry)的start angle,end angle以导入TikZ
- import math
- # SVG path string
- path = 'M 11.71,194.229 A 103.5,103.5 0 0 0 109.185,20.817'
- # Split the path string to get the start and end points of the arc
- _,start_point,_, radius, _, _, _, end_point = path.split()
- radius = float(radius.split(",")[0])
- # Convert the start and end points to floats
- start_x, start_y = map(float, start_point.split(","))
- end_x, end_y = map(float, end_point.split(","))
- # Calculate the start angle using the atan2 function
- start_angle = math.degrees(math.atan2(start_y - radius, start_x))
- # Calculate the end angle using the atan2 function
- end_angle = math.degrees(math.atan2(end_y - radius, end_x))
- print(r"\draw(",start_point,")arc(",start_angle,":",end_angle,":",radius,");")
复制代码
This will output:
\draw( 11.71,194.229 )arc( 82.64573712265114 : -37.13571293426289 : 103.5 );
See 14.7The Arc Operation |