(1)点的缓冲
1.单点定距缓冲:以点为圆心,往往得到一个圆形。
2.单点多距缓冲:形成一个多距缓冲。
(2)线的缓冲
1.单线定距缓冲
2.单线多距缓冲
3.同距缓冲
4.按属性值缓冲
(3)面的缓冲
存在内缓冲和外缓冲之分:
内缓冲:在指定面状要素内部建立缓冲区,可以是单个面状要素,也可以是多个面状要素同时建立;
外缓冲:在指定面状要素外部建立缓冲区,可以是单个面状要素,也可以是多个面状要素同时建立。
(4)程序实现
1 import math 2 import turtle as f 3 4 5 def Buffer_xy(dic_point): 6 DR = 150 7 DL = 200 8 for item, value in dic_point.items(): 9 # # 计算方位角 10 yb_ya = dic_point['B'][1]-dic_point['A'][1] 11 xb_xa = dic_point['B'][0]-dic_point['A'][0] 12 yc_yb = dic_point['C'][1]-dic_point['B'][1] 13 xc_xb = dic_point['C'][0]-dic_point['B'][0] 14 15 fw_AB = math.degrees(math.atan(yb_ya / xb_xa)) 16 if yb_ya > 0 and xb_xa < 0:fw_AB = 180 - fw_AB 17 if yb_ya < 0 and xb_xa < 0:fw_AB = 180 + fw_AB 18 if yb_ya < 0 and xb_xa > 0:fw_AB = 360 - fw_AB 19 20 fw_BC = math.degrees(math.atan(yc_yb / xc_xb)) 21 if yc_yb > 0 and xc_xb < 0:fw_BC = 180 - fw_BC 22 if yc_yb < 0 and xc_xb < 0:fw_BC = 180 + fw_BC 23 if yc_yb < 0 and xc_xb > 0:fw_BC = 360 - fw_BC 24 25 # # 计算BA方位角 26 if fw_AB < 180: fw_BA = fw_AB + 180 27 if fw_AB >= 180: fw_BA = fw_AB - 180 28 # # 计算角西塔B 29 if fw_BC > fw_BA: 30 XTB = fw_BA - fw_BC + 2*180 31 if fw_BC <= fw_BA: 32 XTB = fw_BA - fw_BC 33 # # 计算角贝塔B 34 if fw_BA < fw_BC: 35 BTB = fw_BC + (1/2)*XTB - 2*180 36 if fw_BA >= fw_BC: 37 BTB = fw_BC + (1/2)*XTB 38 # # 计算左右缓冲点坐标 39 X_BL = dic_point['B'][0] - DL*math.cos(BTB) 40 Y_BL = dic_point['B'][1] - DL*math.sin(BTB) 41 X_BR = dic_point['B'][0] + DR*math.cos(BTB) 42 Y_BR = dic_point['B'][1] + DR*math.sin(BTB) 43 BL = (round(X_BL, 3),round(Y_BL, 3)) 44 BR = (round(X_BR, 3),round(Y_BR, 3)) 45 return [BL,BR] 46 47 def Paint(dic_point,BLR): 48 f.setup(width = 0.7, height = 0.6) 49 f.pensize(3) 50 f.hideturtle() 51 f.speed(1) 52 # # 标注A、B、C三点的图标及字母 53 for item,value in dic_point.items(): 54 f.pencolor("red") 55 f.penup() 56 f.goto(value[0],value[1]) 57 f.pendown() 58 f.write('*',font=('黑体',25)) 59 f.penup() 60 f.pencolor('blue') 61 f.goto(value[0]+20,value[1]+20) 62 f.write(item,font=('黑体',30)) 63 # # 连接A、B、C三点 64 f.penup() 65 f.pencolor("black") 66 f.goto(dic_point['A'][0]+10,dic_point['A'][1]+20) 67 f.pendown() 68 f.goto(dic_point['B'][0]+10,dic_point['B'][1]+20) 69 f.goto(dic_point['C'][0]+10,dic_point['C'][1]+20) 70 # # 标注A、B、C三点的坐标 71 f.penup() 72 f.goto(dic_point['A'][0]-50,dic_point['A'][1]-10) 73 f.pendown() 74 f.write(str(dic_point['A']),font=('黑体',12)) 75 f.penup() 76 f.goto(dic_point['B'][0]-25,dic_point['B'][1]-15) 77 f.pendown() 78 f.write(str(dic_point['B']),font=('黑体',12)) 79 f.penup() 80 f.goto(dic_point['C'][0]-50,dic_point['C'][1]-15) 81 f.pendown() 82 f.write(str(dic_point['C']),font=('黑体',12)) 83 # # 标注缓冲点Br、Bl图标及字母 84 f.penup() 85 f.goto(BLR[0][0]-10, BLR[0][1]+10) 86 f.pendown() 87 f.write('*',font=('黑体',15)) 88 f.penup() 89 f.goto(BLR[0][0], BLR[0][1]+20) 90 f.pendown() 91 f.write('Bl',font=('黑体',15)) 92 93 f.penup() 94 f.goto(BLR[1]) 95 f.pendown() 96 f.write('*',font=('黑体',15)) 97 f.penup() 98 f.goto(BLR[1][0], BLR[1][1]+20) 99 f.pendown() 100 f.write('Br',font=('黑体',15)) 101 # # 缓冲点Br、Bl连线 102 f.pencolor('yellow') 103 f.pensize(2) 104 f.penup() 105 f.goto(BLR[0][0]-5,BLR[0][1]+22) 106 f.pendown() 107 f.goto(BLR[1][0]+5,BLR[1][1]+12) 108 f.penup() 109 f.pencolor('black') 110 f.goto(BLR[0][0]+20,BLR[0][1]) 111 f.write(str(BLR[0]),font=('黑体',12)) 112 f.penup() 113 f.goto(BLR[1][0]+20,BLR[1][1]-15) 114 f.write(str(BLR[1]),font=('黑体',12)) 115 # # 标注DL、DR 116 f.penup() 117 f.pencolor('green') 118 f.goto(BLR[1][0]+60, BLR[1][1]+35) 119 f.pendown() 120 f.write('Dr',font=('黑体',20)) 121 f.penup() 122 f.goto(BLR[0][0]-60, BLR[0][1]-10) 123 f.pendown() 124 f.write('Dl',font=('黑体',20)) 125 # # 注释 126 f.penup() 127 f.pencolor('black') 128 f.goto(BLR[1][0], BLR[1][1]-90) 129 f.write('[注]Dr = 150\n Dl = 200',font=('黑体',13)) 130 f.done() 131 132 133 if __name__ == "__main__": 134 dic_point = { 135 'A':(320, -80), 136 'B':(0, -50), 137 'C':(-300, 130), 138 } 139 BLR = Buffer_xy(dic_point) 140 Paint(dic_point,BLR)
来源:https://www.cnblogs.com/skygrass0531/p/12299122.html