Skip to content

Commit 0192054

Browse files
committed
this is supposed to be 1
1 parent c42e749 commit 0192054

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/quality.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ end
9090
Computes the volume and edge-length ratio from four given points
9191
"""
9292
function volume_edge_ratio(a,b,c,d)
93-
t = a - d
94-
u = b - d
95-
v = c - d
96-
volume = dot(t,cross(u,v))/6
97-
edges = (t,u,v,a-b,b-c,a-c)
93+
t = a .- d
94+
u = b .- d
95+
v = c .- d
96+
volume = t[1]*(u[2]*v[3]-v[2]*u[3])-u[1]*(t[2]*v[3]-v[2]*t[3])+v[1]*(t[2]*u[3]-u[2]*t[3])
97+
edges = (t,u,v,a.-b,b.-c,a.-c)
9898
lengths = norm.(edges)
9999
l_rms = sqrt(sum(lengths.^2)/6)
100-
return 6*volume/(sqrt(2)*l_rms^3)
100+
return volume/(sqrt(2)*l_rms^3)
101101
end
102102

103103
"""

test/runtests.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ end
4141
end
4242
@testset "volume-length" begin
4343
pts = ([1,0,-1/sqrt(2)], [-1,0,-1/sqrt(2)], [0,1,1/sqrt(2)], [0,-1,1/sqrt(2)])
44+
pts2 = ([1,1,1], [1,-1,-1], [-1,1,-1], [-1,-1,1])
45+
pts_degenerate = ([1,1,1], [1,1,1], [-1,1,-1], [-1,-1,1])
4446
@show DistMesh.volume_edge_ratio(pts...)
4547
@show DistMesh.volume_edge_ratio((pts.*2)...)
46-
48+
@show DistMesh.volume_edge_ratio((pts.*1e-6)...) 0.5
49+
@test isnan(DistMesh.volume_edge_ratio((pts.*0)...))
50+
@show DistMesh.volume_edge_ratio(pts2...)
51+
@show DistMesh.volume_edge_ratio((pts2.*2)...)
52+
@test DistMesh.volume_edge_ratio(pts_degenerate...) == 0
4753

4854
end
4955
end

0 commit comments

Comments
 (0)