From 4f76d37dff79d69b525a5bf5fc28ffb9f587a02d Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 26 Feb 2015 17:08:33 +1100 Subject: [PATCH] math/f32, math/f64: new packages for vector and matrix types. Change-Id: I937d16429d7321360d0b9f3a811f8d3d719e9bff Reviewed-on: https://go-review.googlesource.com/6076 Reviewed-by: David Crawshaw Reviewed-by: Stephen Gutekanst --- math/f32/f32.go | 25 +++++++++++++++++++++++++ math/f64/f64.go | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 math/f32/f32.go create mode 100644 math/f64/f64.go diff --git a/math/f32/f32.go b/math/f32/f32.go new file mode 100644 index 0000000..7dcc9fc --- /dev/null +++ b/math/f32/f32.go @@ -0,0 +1,25 @@ +// 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 diff --git a/math/f64/f64.go b/math/f64/f64.go new file mode 100644 index 0000000..8fd32ea --- /dev/null +++ b/math/f64/f64.go @@ -0,0 +1,25 @@ +// 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