summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/image/math
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/image/math')
-rw-r--r--vendor/golang.org/x/image/math/f32/f32.go37
-rw-r--r--vendor/golang.org/x/image/math/f64/f64.go37
-rw-r--r--vendor/golang.org/x/image/math/fixed/fixed.go2
-rw-r--r--vendor/golang.org/x/image/math/fixed/fixed_test.go110
4 files changed, 185 insertions, 1 deletions
diff --git a/vendor/golang.org/x/image/math/f32/f32.go b/vendor/golang.org/x/image/math/f32/f32.go
new file mode 100644
index 000000000..4ca1eb47d
--- /dev/null
+++ b/vendor/golang.org/x/image/math/f32/f32.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package f32 implements float32 vector and matrix types.
+package f32 // import "golang.org/x/image/math/f32"
+
+// Vec2 is a 2-element vector.
+type Vec2 [2]float32
+
+// Vec3 is a 3-element vector.
+type Vec3 [3]float32
+
+// Vec4 is a 4-element vector.
+type Vec4 [4]float32
+
+// Mat3 is a 3x3 matrix in row major order.
+//
+// m[3*r + c] is the element in the r'th row and c'th column.
+type Mat3 [9]float32
+
+// Mat4 is a 4x4 matrix in row major order.
+//
+// m[4*r + c] is the element in the r'th row and c'th column.
+type Mat4 [16]float32
+
+// Aff3 is a 3x3 affine transformation matrix in row major order, where the
+// bottom row is implicitly [0 0 1].
+//
+// m[3*r + c] is the element in the r'th row and c'th column.
+type Aff3 [6]float32
+
+// Aff4 is a 4x4 affine transformation matrix in row major order, where the
+// bottom row is implicitly [0 0 0 1].
+//
+// m[4*r + c] is the element in the r'th row and c'th column.
+type Aff4 [12]float32
diff --git a/vendor/golang.org/x/image/math/f64/f64.go b/vendor/golang.org/x/image/math/f64/f64.go
new file mode 100644
index 000000000..a1f7fc0ef
--- /dev/null
+++ b/vendor/golang.org/x/image/math/f64/f64.go
@@ -0,0 +1,37 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package f64 implements float64 vector and matrix types.
+package f64 // import "golang.org/x/image/math/f64"
+
+// Vec2 is a 2-element vector.
+type Vec2 [2]float64
+
+// Vec3 is a 3-element vector.
+type Vec3 [3]float64
+
+// Vec4 is a 4-element vector.
+type Vec4 [4]float64
+
+// Mat3 is a 3x3 matrix in row major order.
+//
+// m[3*r + c] is the element in the r'th row and c'th column.
+type Mat3 [9]float64
+
+// Mat4 is a 4x4 matrix in row major order.
+//
+// m[4*r + c] is the element in the r'th row and c'th column.
+type Mat4 [16]float64
+
+// Aff3 is a 3x3 affine transformation matrix in row major order, where the
+// bottom row is implicitly [0 0 1].
+//
+// m[3*r + c] is the element in the r'th row and c'th column.
+type Aff3 [6]float64
+
+// Aff4 is a 4x4 affine transformation matrix in row major order, where the
+// bottom row is implicitly [0 0 0 1].
+//
+// m[4*r + c] is the element in the r'th row and c'th column.
+type Aff4 [12]float64
diff --git a/vendor/golang.org/x/image/math/fixed/fixed.go b/vendor/golang.org/x/image/math/fixed/fixed.go
index cc7bac79e..df3540a3a 100644
--- a/vendor/golang.org/x/image/math/fixed/fixed.go
+++ b/vendor/golang.org/x/image/math/fixed/fixed.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// Package fixed implements fixed-point integer types.
-package fixed
+package fixed // import "golang.org/x/image/math/fixed"
import (
"fmt"
diff --git a/vendor/golang.org/x/image/math/fixed/fixed_test.go b/vendor/golang.org/x/image/math/fixed/fixed_test.go
new file mode 100644
index 000000000..065ab00b0
--- /dev/null
+++ b/vendor/golang.org/x/image/math/fixed/fixed_test.go
@@ -0,0 +1,110 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package fixed
+
+import (
+ "testing"
+)
+
+var testCases = []struct {
+ x float64
+ s26_6 string
+ s52_12 string
+ floor int
+ round int
+ ceil int
+}{{
+ x: 0,
+ s26_6: "0:00",
+ s52_12: "0:0000",
+ floor: 0,
+ round: 0,
+ ceil: 0,
+}, {
+ x: 1,
+ s26_6: "1:00",
+ s52_12: "1:0000",
+ floor: 1,
+ round: 1,
+ ceil: 1,
+}, {
+ x: 1.25,
+ s26_6: "1:16",
+ s52_12: "1:1024",
+ floor: 1,
+ round: 1,
+ ceil: 2,
+}, {
+ x: 2.5,
+ s26_6: "2:32",
+ s52_12: "2:2048",
+ floor: 2,
+ round: 3,
+ ceil: 3,
+}, {
+ x: 63 / 64.0,
+ s26_6: "0:63",
+ s52_12: "0:4032",
+ floor: 0,
+ round: 1,
+ ceil: 1,
+}, {
+ x: -0.5,
+ s26_6: "-0:32",
+ s52_12: "-0:2048",
+ floor: -1,
+ round: +0,
+ ceil: +0,
+}, {
+ x: -4.125,
+ s26_6: "-4:08",
+ s52_12: "-4:0512",
+ floor: -5,
+ round: -4,
+ ceil: -4,
+}, {
+ x: -7.75,
+ s26_6: "-7:48",
+ s52_12: "-7:3072",
+ floor: -8,
+ round: -8,
+ ceil: -7,
+}}
+
+func TestInt26_6(t *testing.T) {
+ for _, tc := range testCases {
+ x := Int26_6(tc.x * (1 << 6))
+ if got, want := x.String(), tc.s26_6; got != want {
+ t.Errorf("tc.x=%v: String: got %q, want %q", tc.x, got, want)
+ }
+ if got, want := x.Floor(), tc.floor; got != want {
+ t.Errorf("tc.x=%v: Floor: got %v, want %v", tc.x, got, want)
+ }
+ if got, want := x.Round(), tc.round; got != want {
+ t.Errorf("tc.x=%v: Round: got %v, want %v", tc.x, got, want)
+ }
+ if got, want := x.Ceil(), tc.ceil; got != want {
+ t.Errorf("tc.x=%v: Ceil: got %v, want %v", tc.x, got, want)
+ }
+ }
+}
+
+func TestInt52_12(t *testing.T) {
+ for _, tc := range testCases {
+ x := Int52_12(tc.x * (1 << 12))
+ if got, want := x.String(), tc.s52_12; got != want {
+ t.Errorf("tc.x=%v: String: got %q, want %q", tc.x, got, want)
+ }
+ if got, want := x.Floor(), tc.floor; got != want {
+ t.Errorf("tc.x=%v: Floor: got %v, want %v", tc.x, got, want)
+ }
+ if got, want := x.Round(), tc.round; got != want {
+ t.Errorf("tc.x=%v: Round: got %v, want %v", tc.x, got, want)
+ }
+ if got, want := x.Ceil(), tc.ceil; got != want {
+ t.Errorf("tc.x=%v: Ceil: got %v, want %v", tc.x, got, want)
+ }
+ }
+}