ebiten: Rename det to det2x2

det doesn't calculate the actual det of the matrix.
This commit is contained in:
Hajime Hoshi 2020-07-03 12:48:20 +09:00
parent cec32d4f72
commit 5bc09acb41

View File

@ -179,20 +179,20 @@ func (g *GeoM) Skew(skewX, skewY float64) {
g.ty = ty g.ty = ty
} }
func (g *GeoM) det() float64 { func (g *GeoM) det2x2() float64 {
return (g.a_1+1)*(g.d_1+1) - g.b*g.c return (g.a_1+1)*(g.d_1+1) - g.b*g.c
} }
// IsInvertible returns a boolean value indicating // IsInvertible returns a boolean value indicating
// whether the matrix g is invertible or not. // whether the matrix g is invertible or not.
func (g *GeoM) IsInvertible() bool { func (g *GeoM) IsInvertible() bool {
return g.det() != 0 return g.det2x2() != 0
} }
// Invert inverts the matrix. // Invert inverts the matrix.
// If g is not invertible, Invert panics. // If g is not invertible, Invert panics.
func (g *GeoM) Invert() { func (g *GeoM) Invert() {
det := g.det() det := g.det2x2()
if det == 0 { if det == 0 {
panic("ebiten: g is not invertible") panic("ebiten: g is not invertible")
} }