in LeadInOutLib migliorata scelta direzione attacco perpendicolare

This commit is contained in:
luca.mazzoleni
2025-12-18 12:41:18 +01:00
parent 82cd8f5d8c
commit 3136604e14
+14 -3
View File
@@ -101,10 +101,21 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters)
local dCosAngleStart = -EdgePrevious.vtEdge * Edge.vtN
local dCosAngleEnd = EdgeNext.vtEdge * Edge.vtN
local vtLeadInOut
if dCosAngleStart > dCosAngleEnd then
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
-- se le due direzioni sono entro i 5° scelgo quella a Z assoluta minore, altrimenti quella più vicino alla perpendicolare
-- massima differenza scalare per variazione di 5deg: cos(0) - cos(0 + 5) = 1 - cos(5)
local dScalarTolerance = 1 - 0.996
if abs( dCosAngleStart - dCosAngleEnd) < dScalarTolerance then
if abs( EdgePrevious.vtEdge:getZ()) < abs( EdgeNext.vtEdge:getZ()) then
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
else
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
end
else
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
if dCosAngleStart > dCosAngleEnd then
vtLeadInOut = Vector3d( -EdgePrevious.vtEdge)
else
vtLeadInOut = Vector3d( EdgeNext.vtEdge)
end
end
-- direzione nel frame solidale al lato di lavoro