Flac3D通过fish实现(位移)测线功能

Flac3D通过fish实现(位移)测线功能

s:开始的点(向量)
e:结束的点(向量)
space:取点的步长
direction:获取哪个方向的位移
file:数据保存的文件名称

fish define func(s, e, space, direction, filename)
    local space_x = 0
    local space_y = 0
    local space_z = 0
    local length = 0
    local loop_num = 0
    
    if comp.x(s) - comp.x(e) # 0 then
        space_x = space
        length = math.abs(comp.x(s) - comp.x(e))
    else if comp.y(s) - comp.y(e) # 0 then
        space_y = space
        length = math.abs(comp.y(s) - comp.y(e))
    else if comp.z(s) - comp.z(e) # 0 then
        space_z = space
        length = math.abs(comp.z(s) - comp.z(e))
    else
        io.out("start point and end point is equivalent")
    endif
        
    io.out("the line`s length is " + [string(length)])
    
    if length % space = 0 then
        loop_num = int(length / space)
    else
        loop_num = int(length / space) + 1
    endif
    
    disp_array = array.create(loop_num)
    
    loop i (0, loop_num-1)
        if i < loop_num-1
            x_point = comp.x(s) + space_x * i
            y_point = comp.y(s) + space_y * i
            z_point = comp.z(s) + space_z * i
            
            gp = gp.near(x_point, y_point, z_point)
        else
            gp = gp.near(comp.x(e), comp.y(e), comp.z(e))

        endif
        
        if direction = "x" then
            disp_array(i+1) = gp.disp.x(gp)
        else if direction = "y" then
            disp_array(i+1) = gp.disp.y(gp)
        else if direction = "z" then
            disp_array(i+1) = gp.disp.z(gp)
        endif
    endloop
    file.open(filename, 1, 1)
    f.write(disp_array, loop_num)
    f.close()
end

执行命令行

[global s_point = vector(15,15,13)]
[global e_point = vector(15,15,25)]
@func([s_point],[e_point],1,"z","m.txt")
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值