Find the max separation between poly1 and poly2 using edge normals from poly1.
(edgeIndex *int, poly1 *B2PolygonShape, xf1 B2Transform, poly2 *B2PolygonShape, xf2 B2Transform)
| 2 | |
| 3 | // Find the max separation between poly1 and poly2 using edge normals from poly1. |
| 4 | func B2FindMaxSeparation(edgeIndex *int, poly1 *B2PolygonShape, xf1 B2Transform, poly2 *B2PolygonShape, xf2 B2Transform) float64 { |
| 5 | count1 := poly1.M_count |
| 6 | count2 := poly2.M_count |
| 7 | n1s := poly1.M_normals |
| 8 | v1s := poly1.M_vertices |
| 9 | v2s := poly2.M_vertices |
| 10 | |
| 11 | xf := B2TransformMulT(xf2, xf1) |
| 12 | |
| 13 | bestIndex := 0 |
| 14 | maxSeparation := -B2_maxFloat |
| 15 | for i := 0; i < count1; i++ { |
| 16 | // Get poly1 normal in frame2. |
| 17 | n := B2RotVec2Mul(xf.Q, n1s[i]) |
| 18 | v1 := B2TransformVec2Mul(xf, v1s[i]) |
| 19 | |
| 20 | // Find deepest point for normal i. |
| 21 | si := B2_maxFloat |
| 22 | for j := 0; j < count2; j++ { |
| 23 | sij := B2Vec2Dot(n, B2Vec2Sub(v2s[j], v1)) |
| 24 | if sij < si { |
| 25 | si = sij |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | if si > maxSeparation { |
| 30 | maxSeparation = si |
| 31 | bestIndex = i |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | *edgeIndex = bestIndex |
| 36 | return maxSeparation |
| 37 | } |
| 38 | |
| 39 | func B2FindIncidentEdge(c []B2ClipVertex, poly1 *B2PolygonShape, xf1 B2Transform, edge1 int, poly2 *B2PolygonShape, xf2 B2Transform) { |
| 40 |
no test coverage detected