现在的位置: 首页 > 综合 > 正文

Gambit Journal 学习笔记之一

2013年10月26日 ⁄ 综合 ⁄ 共 1357字 ⁄ 字号 评论关闭
在 Gambit 使用过程中,Journal 可以大大简化重复性的操作,避免疯狂点击各种按钮、文本框、下拉框。Gambit Journal 的语法相对比较简单,但涉及的内容不少,所以特做这个笔记,以促进学习研究。

这次学习的内容比较简单,主要是单变量和数组的使用,点和直线的生成。先看看 journal 文件的内容和生成的结果。

  1. / vertices.jou
  2. / A simple test.
  3. / Begin variables section
  4. /
  5. $point_x=0.0
  6. $point_y=0.0
  7. $point_z=0.0

  8. declare $points[1:3]
  9. $points[1]=1.0
  10. $points[2]=0.0
  11. $points[3]=0.0

  12. declare $points2d[1:2,1:2]
  13. $points2d[1,1]=1.0
  14. $points2d[1,2]=1.0
  15. $points2d[2,1]=0.0
  16. $points2d[2,2]=1.0
  17. /
  18. / End variables section
  19. /
  20. /
  21. / Begin clear section
  22. / delete all edges
  23. edge delete lowertopology
  24. / delete all vertices
  25. vertex delete
  26. / End clear section
  27. /
  28. /
  29. / Begin vertex section
  30. /
  31. vertex create "A" coordinates $point_x $point_y $point_z
  32. vertex create "B" coordinates $points[1] $points[2] $points[3]
  33. vertex create "C" coordinates $points2d[1,1] $points2d[1,2]
  34. vertex create "D" coordinates $points2d[2,1] $points2d[2,2]
  35. /
  36. / End vertex section
  37. /
  38. /
  39. / Begin edge section
  40. /
  41. edge create "line1" straight "A" "C"
  42. /
  43. / End edge section

1 单变量

单变量的使用很简单,定义和使用的时候加一个 $ 符号即可。至于类型的话,应该都是浮点类型,窃认为是 double

  1. $var=0.0
  2. vertex create "A" coordinates $var

2 数组

数组的编号从 1 开始,下标通过 [] 来表示,使用的时候也要加 $ 符号。值得注意的是定义的格式。定义时,通过 1:x 来给出下标的范围。至于维数的限制还有待研究。

  1. declare $points[1:3]
  2. $points[1]=1.0
  3. $points[2]=0.0
  4. $points[3]=0.0

3 点和直线的生成

点和直线的生成很简单,指定名称和组成的元素即可。需要说明的是,生成 vertex 的时候, y 和 z 的默认值为 0.0。

  1. vertex create "A" coordinates $point_x $point_y $point_z
  2. edge create "line1" straight "A" "C"

4 注释

Gambit journal 中的注释格式为

  1. / This is a comment line.

(待续)

抱歉!评论已关闭.