You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/contactDetection/ContactDetectionMPR/mpr.jl
+21-9Lines changed: 21 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -81,19 +81,19 @@ function checkIfShapesArePlanar(r0::SupportPoint,r1::SupportPoint,r2::SupportPoi
81
81
n3 =cross(r1.p-r0.p, r2.p-r0.p)
82
82
neps = Modia3D.nepsType(T)
83
83
# the triangle r0-r1-r2 has degenerated into a line segment
84
+
# println("norm(n3) = ", norm(n3))
84
85
ifnorm(n3) <= neps
85
86
# change search direction for r2
86
87
# because we are still interested in distances if shapes are not intersecting
87
88
n2 =-n2
88
89
r2 =getSupportPoint(shapeA, shapeB, n2)
89
-
ifabs(dot((r2.p-r1.p),n2)) <= neps
90
+
n3 =cross(r1.p-r0.p, r2.p-r0.p) # new normal to the triangle plane (r0-r1-r2_new)
91
+
ifnorm(n3) <= neps
90
92
# Shape is purely planar. Computing the shortest distance for a planar shape
91
93
# requires an MPR 2D algorithm (using lines instead of triangles as portals).
92
94
# However, this is not implemented and therefore the shortest distance cannot be computed
93
-
error("MPR: Shapes are planar and MPR2D is not supported. abs(dot((r2.p-r1.p),n2)). Look at $(Modia3D.fullName(shapeA)) and $(Modia3D.fullName(shapeB)).")
95
+
error("MPR: Shapes are planar and MPR2D is not supported. norm(cross(r1.p-r0.p, r2.p-r0.p)). Look at $(Modia3D.fullName(shapeA)) and $(Modia3D.fullName(shapeB)).")
94
96
end
95
-
# new normal to the triangle plane (r0-r1-r2_new)
96
-
n3 =cross(r1.p-r0.p, r2.p-r0.p) # |n3| > 0 guaranteed, due to construction
97
97
end
98
98
99
99
ifdot(n3,r0.p) >=0.0
@@ -103,14 +103,15 @@ function checkIfShapesArePlanar(r0::SupportPoint,r1::SupportPoint,r2::SupportPoi
103
103
# check if portal triangle r1-r2-r3 has degenerated into a line segment <--> points r1,r2,r3 are on the same line
# Shape is purely planar. Computing the shortest distance for a planar shape
111
112
# requires an MPR 2D algorithm (using lines instead of triangles as portals).
112
113
# However, this is not implemented and therefore the shortest distance cannot be computed
113
-
error("MPR: Shapes are planar and MPR2D is not supported. r1, r2, r3 are on the same ray. abs(dot((r3.p-r1.p),r3.n)) <= neps. Look at $(Modia3D.fullName(shapeA)) and $(Modia3D.fullName(shapeB)).")
114
+
error("MPR: Shapes are planar and MPR2D is not supported. r1, r2, r3 are on the same ray. norm(cross(r2.p-r1.p, r3.p-r1.p)) <= neps. Look at $(Modia3D.fullName(shapeA)) and $(Modia3D.fullName(shapeB)).")
114
115
end
115
116
end
116
117
@@ -162,15 +163,16 @@ function constructR4(r0::SupportPoint,r1::SupportPoint,r2::SupportPoint,r3::Supp
162
163
r4 = SupportPoint{T}
163
164
n4 =cross(r2.p-r1.p, r3.p-r1.p)
164
165
neps = Modia3D.nepsType(T)
166
+
# println("norm(n4) = ", norm(n4))
165
167
ifnorm(n4) <= neps
166
168
r3 =getSupportPoint(shapeA, shapeB, -r3.n, scale=scale) # change search direction
167
-
ifabs(dot((r3.p-r1.p),r3.n)) <= neps
169
+
n4 =cross(r2.p-r1.p, r3.p-r1.p)
170
+
ifnorm(n4) <= neps
168
171
# Shape is purely planar. Computing the shortest distance for a planar shape
169
172
# requires an MPR 2D algorithm (using lines instead of triangles as portals).
170
173
# However, this is not implemented and therefore the shortest distance cannot be computed
171
-
error("MPR: Shapes are planar and MPR2D is not supported. abs(dot((r3.p-r1.p),r3.n)). Look at $(Modia3D.fullName(shapeA)) and $(Modia3D.fullName(shapeB)).")
174
+
error("MPR: Shapes are planar and MPR2D is not supported. norm(n4). Look at $(Modia3D.fullName(shapeA)) and $(Modia3D.fullName(shapeB)).")
172
175
end
173
-
n4 =cross(r2.p-r1.p, r3.p-r1.p) # |n4| > 0 guaranteed, due to construction
174
176
end
175
177
ifdot(n4,r0.p) >=0.0
176
178
n4 =-n4
@@ -244,6 +246,7 @@ function finalTC3(r0::SupportPoint{T}, r1::SupportPoint{T}, r2::SupportPoint{T},
0 commit comments