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

Method Solve

CommonB2Math.go:299–315  ·  view source on GitHub ↗

Solve A * x = b, where b is a column vector. This is more efficient than computing the inverse in one-shot cases.

(b B2Vec2)

Source from the content-addressed store, hash-verified

297/// Solve A * x = b, where b is a column vector. This is more efficient
298/// than computing the inverse in one-shot cases.
299func (m B2Mat22) Solve(b B2Vec2) B2Vec2 {
300
301 a11 := m.Ex.X
302 a12 := m.Ey.X
303 a21 := m.Ex.Y
304 a22 := m.Ey.Y
305 det := a11*a22 - a12*a21
306
307 if det != 0.0 {
308 det = 1.0 / det
309 }
310
311 return MakeB2Vec2(
312 det*(a22*b.X-a12*b.Y),
313 det*(a11*b.Y-a21*b.X),
314 )
315}
316
317///////////////////////////////////////////////////////////////////////////////
318/// A 3-by-3 matrix. Stored in column-major order.

Callers 2

Calls 1

MakeB2Vec2Function · 0.85

Tested by

no test coverage detected