⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2.6.grs

📁 UG二次开发很好的东西 需要的朋友可以下载来看看 很好用啊
💻 GRS
字号:
$$实体变量和数字数组变量声明。
entity/ln1,ln2,pt1,pt2,pt3
number/a(3),b(3),c(3)

$$在UG窗口中选择第一条直线ln1。
l10:
ident/'pick  line 1',ln1,resp
jump/l10:,trm:,,resp

$$在UG窗口中选择第二条直线ln2。
l20:
ident/'pick  line 2',ln2,resp
jump/l20:,trm:,,resp

$$确定两条直线的交点pt1。
l30:
pt1=point/intof,ln1,ln2
a(1..3)=&point(pt1)
$$确定直线ln1的另一端点pt2。
b(1..3)=&spoint(ln1)
c(1..3)=&epoint(ln1)
ifthen/a(1)==c(1) and a(2)==c(2) and a(3)==c(3)
pt2=point/b(1..3)
elseif/a(1)==b(1) and a(2)==b(2) and a(3)==b(3)
pt2=point/c(1..3)
else
jump/trm:
endif
$$确定直线ln2的另一端点pt3。
b(1..3)=&spoint(ln2)
c(1..3)=&epoint(ln2)
ifthen/a(1)==c(1) and a(2)==c(2) and a(3)==c(3)
pt3=point/b(1..3)
elseif/a(1)==b(1) and a(2)==b(2) and a(3)==b(3)
pt3=point/c(1..3)
else
jump/trm:
endif
$$调用子程序'2-points-dis'分别计算点pt1和pt2距离dis1,pt1和pt3距离dis2以及pt2。
$$和pt3距离dis3
call/'2-points-dis',pt1,pt2,dis1   
call/'2-points-dis',pt1,pt3,dis2
call/'2-points-dis',pt3,pt2,dis3
$$利用dis1、dis2和dis3计算夹角的余弦值,从而确定两直线的角度。
arg=(dis1*dis1+dis2*dis2-dis3*dis3)/(2*dis1*dis2)
ang=acosf(arg)
delete/pt1,pt2,pt3
print/ang

trm:
halt

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -