Hide Color.Dim / Geometry.Dim

This commit is contained in:
Hajime Hoshi 2014-12-07 23:20:41 +09:00
parent 05c0cb5531
commit 4c79f1bccd
3 changed files with 6 additions and 6 deletions

View File

@ -1,13 +1,13 @@
package matrix package matrix
type affine interface { type affine interface {
Dim() int dim() int
element(i, j int) float64 element(i, j int) float64
setElement(i, j int, element float64) setElement(i, j int, element float64)
} }
func isIdentity(matrix affine) bool { func isIdentity(matrix affine) bool {
dim := matrix.Dim() dim := matrix.dim()
for i := 0; i < dim-1; i++ { for i := 0; i < dim-1; i++ {
for j := 0; j < dim; j++ { for j := 0; j < dim; j++ {
element := matrix.element(i, j) element := matrix.element(i, j)
@ -22,8 +22,8 @@ func isIdentity(matrix affine) bool {
} }
func mul(lhs, rhs, result affine) { func mul(lhs, rhs, result affine) {
dim := lhs.Dim() dim := lhs.dim()
if dim != rhs.Dim() { if dim != rhs.dim() {
panic("diffrent-sized matrices can't be multiplied") panic("diffrent-sized matrices can't be multiplied")
} }

View File

@ -22,7 +22,7 @@ func ColorI() Color {
} }
} }
func (matrix *Color) Dim() int { func (matrix *Color) dim() int {
return ColorDim return ColorDim
} }

View File

@ -19,7 +19,7 @@ func GeometryI() Geometry {
} }
} }
func (matrix *Geometry) Dim() int { func (matrix *Geometry) dim() int {
return GeometryDim return GeometryDim
} }