找回密码
 注册
Simdroid-非首页
查看: 217|回复: 2

[工程实例] PFC3D5.0球体规则排列操作实例代码

[复制链接]
发表于 2016-12-22 16:45:33 | 显示全部楼层 |阅读模式 来自 湖南长沙
  1. ; fname: ball_gen.p3dat
  2. ; 问题描述:按照矩形排列生成9*9的颗粒平面;按照六边形排列生成9*9颗粒平面。
  3. new
  4. domain extent -40 40

  5. def orthogon_arrange
  6.     local ini_x = -21.0
  7.     local ini_y = 0.0
  8.     local ini_z = 5.0
  9.     local ini_rad = 1.0
  10.     loop local n(1,9)
  11.         o_x = ini_x
  12.         o_y = ini_y
  13.         o_z = ini_z + 2.0*(n-1)*ini_rad
  14.         loop local m(1,9)
  15.             command
  16.                 ball create group arrange_one ...
  17.                      radius @ini_rad x @o_x y @o_y z @o_z
  18.             ;pause key
  19.             end_command
  20.             o_x = ini_x + 2.0*ini_rad*m
  21.         end_loop
  22.     end_loop
  23. end
  24. @orthogon_arrange

  25. def hexagon_arrange
  26.     local ini_x = 5.0
  27.     local ini_y = 0.0
  28.     local ini_z = 5.0
  29.     local ini_rad = 1.0
  30.     loop local n(1,9)
  31.         h_y = ini_y
  32.         h_z = ini_z + (n-1)*ini_rad*math.sqrt(3.0)
  33.         test_n = n/2
  34.         if (test_n*2 - n) < 0 then
  35.         h_x = ini_x
  36.         else
  37.         h_x = ini_x + ini_rad
  38.         end_if
  39.         loop local m (1,9)
  40.             command
  41.                 ball create group arrange_two ...
  42.                      radius @ini_rad x @h_x y @h_y z @h_z
  43.             end_command
  44.             h_x += 2.0*ini_rad
  45.         end_loop
  46.     end_loop
  47. end
  48. @hexagon_arrange

  49. ball generate group arrange_three ...
  50.      box -21 -5 -0.5 0.5 -21 -5 ...
  51.      radius 1.0 cubic
  52. ball generate group arrange_four ...
  53.      box 5 22 -0.5 0.5 -19 -5 ...
  54.      radius 1.0 hexagon
复制代码


规则排列效果图

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2016-12-24 23:05:18 | 显示全部楼层 来自 山东济南
赞一个,楼主威武
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-4-16 20:02 , Processed in 0.029577 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表