### Defining parameters of mountain

Hi,

I really need help with c++ code made a 3d program where i want to simulate a grupp of particles going down mountain. Below is written code for mountain definition which i c/p from one example. Is there anybody who can explain what does lines mean (at least these bolt lines). what is their purpose? i'm begginer in programming so i would really appriciate if someone can explain...

def mountain
; check for existing balls and kill them
command
del balls
end_command
; check for existing hill, kill it if it exists
if mt_start_id > 0
_start_id = mt_start_id
_end_id = mt_end_id
zap_walls
endif
if mt_nodes < 2 ; keep it tidy
mt_nodes = 2
endif
wall_id = max_wid + 1 ; get starting id for slope
mt_start_id = wall_id ; save it so we can kill the walls
x0 = 0.0 ; we start at the origin and go right
y0 = 0.0 ; and down
xtable(1,1) = x0 ; table 1 contains x,y coord pairs
ytable(1,1) = y0 ; table 2 contains slope/convexity data
loop i (2, mt_nodes+1)
xtable(1,i)=xtable(1,i-1)+urand*10.0
ytable(1,i)=ytable(1,i-1)-urand*10.0*mt_steep
_temp=float(xtable(1,i)-xtable(1,i-1))
xtable(2,i)=(ytable(1,i)-ytable(1,i-1))/_temp
endloop
loop i (2, mt_nodes+1)
if xtable(2,i+1) <= xtable(2,i) then
ytable(2,i) = 0 ; convex at node
else
ytable(2,i) = 1 ; concave at node
endif
endloop
x1 = xtable(1,1)
z1 = ytable(1,1)
x2 = xtable(1,2)
z2 = ytable(1,2)
command

wall id wall_id kn mt_kn ks mt_ks fric mt_fric face &
(x1 0.0 z1) (x2 0.0 z2) (x2 mt_depth z2) (x1 mt_depth z1)
endcommand

loop i (2, mt_nodes)
if ytable(2,i) = 0 ; convex, so add segment
x1 = x2
z1 = z2
x2 = xtable(1,i+1)
z2 = ytable(1,i+1)
command
wall id wall_id kn mt_kn ks mt_ks fric mt_fric face &
(x1 0.0 z1) (x2 0.0 z2) (x2 mt_depth z2) (x1 mt_depth z1)
endcommand
else ; concave, so add new wall
x1 = xtable(1,i)
z1 = ytable(1,i)
x2 = xtable(1,i+1)
z2 = ytable(1,i+1)
wall_id = wall_id + 1
command
wall id wall_id kn mt_kn ks mt_ks fric mt_fric face &
(x1 0.0 z1) (x2 0.0 z2) (x2 mt_depth z2) (x1 mt_depth z1)
endcommand
endif
endloop
x1 = xtable(1,mt_nodes+1) ; make a landing zone
z1 = ytable(1,mt_nodes+1)
x2 = x1 * 2.0
z2 = z1
wall_id = wall_id + 1
command
wall id wall_id kn mt_kn ks mt_ks fric mt_fric face &
(x1 0.0 z1) (x2 0.0 z2) (x2 mt_depth z2) (x1 mt_depth z1)
endcommand
mt_end_id = wall_id
;
; create infinite walls bounding the slope
wall_id = wall_id + 101
command
wall id wall_id kn mt_kn ks mt_ks fric mt_fric origin (0,0,0) &
normal (0,1,0)
endcommand
wall_id = wall_id + 1
command
wall id wall_id kn mt_kn ks mt_ks fric mt_fric origin (0,mt_depth,0) &
normal (0,-1,0)
endcommand
end
Topic archived. No new replies allowed.