From 61d7f1e9b5c370307fc45ecdb0f4a670efe8356f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 12 Mar 2018 11:11:53 +0900 Subject: [PATCH] affine: Bug fix: (*GeoM).det() was wrong (#547) --- geom_test.go | 9 +++++++++ internal/affine/geom.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/geom_test.go b/geom_test.go index 176d3f4fc..bdb289d8a 100644 --- a/geom_test.go +++ b/geom_test.go @@ -201,6 +201,11 @@ func TestGeoMIsInvert(t *testing.T) { cpx.Scale(1.5, 2.5) cpx.Translate(-2, -3) + cpx2 := GeoM{} + cpx2.Scale(2, 3) + cpx2.Rotate(0.234) + cpx2.Translate(100, 100) + cases := []struct { GeoM GeoM Invertible bool @@ -225,6 +230,10 @@ func TestGeoMIsInvert(t *testing.T) { GeoM: cpx, Invertible: true, }, + { + GeoM: cpx2, + Invertible: true, + }, } pts := []struct { diff --git a/internal/affine/geom.go b/internal/affine/geom.go index 6cb73f0d6..adaf708ee 100644 --- a/internal/affine/geom.go +++ b/internal/affine/geom.go @@ -188,7 +188,7 @@ func (g *GeoM) det() float64 { if g == nil { return 1 } - 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 } func (g *GeoM) IsInvertible() bool {