Skip to content

Commit 5cad95f

Browse files
authored
Merge pull request #118 from ModiaSim/gh_improveFileMeshSupportPointCalculation
Improve efficiency of FileMesh support point calculation
2 parents a228fd3 + d575721 commit 5cad95f

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/Shapes/boundingBoxes.jl

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,17 @@ end
247247

248248
# [Gino v.d. Bergen, p. 131]
249249
@inline function supportPoint_abs_FileMesh(shape::FileMesh, e_abs::SVector{3,T}) where {T}
250-
#e_absVec = Vector{SVector{3,Float64}}(undef, 1)
251-
#e_absVec[1] = e_abs
252-
#(max_value, position) = findmax(broadcast(dot, shape.objPoints, e_absVec))
253-
#return SVector{3,T}(shape.objPoints[position])
254-
iMax::Int = 1
255-
dotMax::T = typemin(T)
256-
objPoints = shape.objPoints
257-
for i in 2:length(shape.objPoints)
258-
doti = dot(objPoints[i],e_abs)
259-
if doti > dotMax
260-
iMax = i
261-
dotMax = doti
250+
dirvec = SVector{3,Float64}(e_abs)
251+
idxmax = 1
252+
dotmax = typemin(Float64)
253+
for idx in eachindex(shape.objPoints)
254+
dotval = dot(shape.objPoints[idx], dirvec)
255+
if dotval > dotmax
256+
idxmax = idx
257+
dotmax = dotval
262258
end
263-
end
264-
return objPoints[iMax]
259+
end
260+
return SVector{3,T}(shape.objPoints[idxmax])
265261
end
266262

267263

0 commit comments

Comments
 (0)