Skip to content

Commit

Permalink
Merge pull request #118 from ModiaSim/gh_improveFileMeshSupportPointC…
Browse files Browse the repository at this point in the history
…alculation

Improve efficiency of FileMesh support point calculation
  • Loading branch information
MartinOtter authored Sep 9, 2022
2 parents a228fd3 + d575721 commit 5cad95f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/Shapes/boundingBoxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,17 @@ end

# [Gino v.d. Bergen, p. 131]
@inline function supportPoint_abs_FileMesh(shape::FileMesh, e_abs::SVector{3,T}) where {T}
#e_absVec = Vector{SVector{3,Float64}}(undef, 1)
#e_absVec[1] = e_abs
#(max_value, position) = findmax(broadcast(dot, shape.objPoints, e_absVec))
#return SVector{3,T}(shape.objPoints[position])
iMax::Int = 1
dotMax::T = typemin(T)
objPoints = shape.objPoints
for i in 2:length(shape.objPoints)
doti = dot(objPoints[i],e_abs)
if doti > dotMax
iMax = i
dotMax = doti
dirvec = SVector{3,Float64}(e_abs)
idxmax = 1
dotmax = typemin(Float64)
for idx in eachindex(shape.objPoints)
dotval = dot(shape.objPoints[idx], dirvec)
if dotval > dotmax
idxmax = idx
dotmax = dotval
end
end
return objPoints[iMax]
end
return SVector{3,T}(shape.objPoints[idxmax])
end


Expand Down

0 comments on commit 5cad95f

Please sign in to comment.