$$ 3点圆弧(端点、端点、圆上任意点)
gripsw / declrv
entity / pt(4),ln
number / num(4,3),r,aa(3)
number / resp,a,b,c,d,e,f,x,y
l10:
gpos/'梅雷提示!请选择端点1。',num(1,1..3),resp
jump/l10:,end:,,,resp
l20:
gpos/'梅雷提示!请选择端点2。',num(2,1..3),resp
jump/l10:,end:,,,resp
l30:
gpos/'梅雷提示!请选择任意点。',num(3,1..3),resp
jump/l20:,end:,,,resp
num(1,3)=0
num(2,3)=0
num(3,3)=0
ifthen/num(1,1..2)==num(3,1..2) and num(2,1..2)==num(3,1..2)
messg/'梅雷提示!3点不能共线。'
JUMP/L30:
endif
$$ 根据3点获得圆心num(4,1..3)和半径r
a=2*(num(2,1)-num(1,1))
b=2*(num(2,2)-num(1,2))
c=num(2,1)*num(2,1)+num(2,2)*num(2,2)-num(1,1)*num(1,1)-num(1,2)*num(1,2)
d=2*(num(3,1)-num(2,1))
e=2*(num(3,2)-num(2,2))
f=num(3,1)*num(3,1)+num(3,2)*num(3,2)-num(2,1)*num(2,1)-num(2,2)*num(2,2)
x=(b*f-e*c)/(b*d-e*a)
y=(d*c-a*f)/(b*d-e*a)
r=sqrtf((x-num(1,1))*(x-num(1,1))+(y-num(1,2))*(y-num(1,2)))
num(4,1)=x
num(4,2)=y
num(4,3)=0
pt(1)=point/num(1,1..3)
pt(2)=point/num(3,1..3)
pt(3)=point/num(2,1..3)
pt(4)=point/num(4,1..3)
aa(1)=ANGLF(pt(4),pt(1))
aa(2)=ANGLF(pt(4),pt(2))
if/aa(2)<aa(1),aa(2)=aa(2)+360
aa(3)=ANGLF(pt(4),pt(3))
if/aa(3)<aa(2),aa(3)=aa(3)+360
if/aa(3)<aa(2),aa(3)=aa(3)+360
ifthen/aa(3)-aa(1)>360
ln=circle/pt(3),pt(2),pt(1)
else
ln=circle/pt(1),pt(2),pt(3)
endif
if/a(3)-a(1)==0,jump/L3:
delete/pt
end:
halt
L3:
messg/'梅雷提示!无效的三点,请重新选择。'
jump/L10:
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/
|