@@ -8,9 +8,9 @@ function triqual(p1, p2, p3)
8
8
d13 = p3 - p1
9
9
d23 = p3 - p2
10
10
n = cross (d12,d13)
11
- vol = sqrt (sum (n.^ 2 ))/ 2
11
+ vol = sqrt (sum (n.^ 2 ))
12
12
den = dot (d12,d12) + dot (d13,d13) + dot (d23,d23)
13
- return sqrt (3 )* 4 * vol/ den
13
+ return sqrt (3 )* 2 * vol/ den
14
14
end
15
15
16
16
function triangle_qualities (p,tets)
32
32
33
33
function triangle_qualities! (tris:: Vector ,qualities:: Vector ,p,tets)
34
34
triangle_qualities! (tris,Set {eltype(tris)} (),qualities,p,tets)
35
- end
35
+ end
36
+
37
+ const ⋅ = dot
38
+ const × = cross
39
+
40
+ function dihedral (p0,p1,p2,p3)\
41
+ b1 = p1 - p0
42
+ b2 = p2 - p1
43
+ b3 = p3 - p2
44
+
45
+ abs (atan (((b1× b2)× (b2× b3))⋅ normalize (b2), (b1× b2)⋅ (b2× b3)))
46
+ end
47
+
48
+ """
49
+ Compute dihedral angles within a tetrahedra
50
+ radians
51
+ """
52
+ function dihedral_angles (p,t)
53
+ AT = eltype (eltype (p))
54
+ nangs = length (t)* 6
55
+ a = fill (zero (AT), nangs)
56
+ for i in 1 : length (t)
57
+ t1, t2, t3, t4 = t[i]
58
+ a[i* 6 - 5 ] = dihedral (p[t1],p[t2],p[t3],p[t4])
59
+ a[i* 6 - 4 ] = dihedral (p[t1],p[t2],p[t4],p[t3])
60
+ a[i* 6 - 3 ] = dihedral (p[t2],p[t1],p[t4],p[t3])
61
+ a[i* 6 - 2 ] = dihedral (p[t2],p[t3],p[t4],p[t1])
62
+ a[i* 6 - 1 ] = dihedral (p[t2],p[t1],p[t3],p[t4])
63
+ a[i* 6 ] = dihedral (p[t3],p[t1],p[t2],p[t4])
64
+ end
65
+ a
66
+ end
67
+
68
+ """
69
+ Compute the minimum dihedral angle within a tetrahedra
70
+ radians
71
+ """
72
+ function min_dihedral_angles (p,t)
73
+ AT = eltype (eltype (p))
74
+ nangs = length (t)
75
+ a = fill (zero (AT), nangs)
76
+ for i in 1 : length (t)
77
+ t1, t2, t3, t4 = t[i]
78
+ d = (dihedral (p[t1],p[t2],p[t3],p[t4]),
79
+ dihedral (p[t1],p[t2],p[t4],p[t3]),
80
+ dihedral (p[t2],p[t1],p[t4],p[t3]),
81
+ dihedral (p[t2],p[t3],p[t4],p[t1]),
82
+ dihedral (p[t2],p[t1],p[t3],p[t4]),
83
+ dihedral (p[t3],p[t1],p[t2],p[t4]))
84
+ a[i] = minimum (d)
85
+ end
86
+ a
87
+ end
0 commit comments