MCPcopy Create free account
hub / github.com/ByteArena/box2d / GetSearchDirection

Method GetSearchDirection

CollisionB2Distance.go:307–329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

305}
306
307func (simplex B2Simplex) GetSearchDirection() B2Vec2 {
308 switch simplex.M_count {
309 case 1:
310 return simplex.M_vs[0].W.OperatorNegate()
311
312 case 2:
313 {
314 e12 := B2Vec2Sub(simplex.M_vs[1].W, simplex.M_vs[0].W)
315 sgn := B2Vec2Cross(e12, simplex.M_vs[0].W.OperatorNegate())
316 if sgn > 0.0 {
317 // Origin is left of e12.
318 return B2Vec2CrossScalarVector(1.0, e12)
319 } else {
320 // Origin is right of e12.
321 return B2Vec2CrossVectorScalar(e12, 1.0)
322 }
323 }
324
325 default:
326 B2Assert(false)
327 return B2Vec2_zero
328 }
329}
330
331func (simplex B2Simplex) GetClosestPoint() B2Vec2 {
332 switch simplex.M_count {

Callers 1

B2DistanceFunction · 0.80

Calls 6

B2Vec2SubFunction · 0.85
B2Vec2CrossFunction · 0.85
B2Vec2CrossScalarVectorFunction · 0.85
B2Vec2CrossVectorScalarFunction · 0.85
B2AssertFunction · 0.85
OperatorNegateMethod · 0.45

Tested by

no test coverage detected