Skip to main content
. Author manuscript; available in PMC: 2018 Nov 1.
Published in final edited form as: J Biomed Inform. 2017 Sep 22;75:48–62. doi: 10.1016/j.jbi.2017.09.010

Algorithm 3.

Capturing needle penetration of penrose drain

1: procedure captureNeedlePenetration
2:  set toggle = 0 at start of simulation
3: if toggle == 0 then
4:   for each surface triangle of penrose drain do
5:    find vector w0 = x0xa
6:    if |w0| > DT then
7:     continue to next triangle (broad phase elimination)
8:    end if
9:    find outward normal of the triangle
10:    find projected penetration point P = xa + (w0.)
11:    if P lies outside the triangle then
12:     continue to next triangle
13:    end if
14:    compute vectors w and w1
15:    if w.w1 < 0 then
16:     set toggle = 1
17:     identify triangle
18:     initiate penetration
19:    end if
20:   end for
21: end if
22: if toggle == 1 then
23:   compute vectors w w1 and w2 in identified triangle
21:   if w1.w2 ≤ 0 then
25:    set toggle = 0
26:    confirm penetration
27:   end if
28:   if w.w1 ≥ 0 and w1.w2 ≥ 0 then
29:    set toggle = 0
30:    no penetration
31:   end if
32: end if
33: end procedure