ungerik / go3d

A performance oriented 2D/3D math package for Go
MIT License
303 stars 49 forks source link

MulVec3 is broken #12

Closed blezek closed 9 years ago

blezek commented 9 years ago

Hi, This code in float64/mat3/mat3.go is broken:

func (mat *T) MulVec3(v *vec3.T) vec3.T {
return vec3.T{
mat[0][0]*v[0] + mat[1][0]*v[1] + mat[2][0]*v[2],
mat[0][1]*v[1] + mat[1][1]*v[1] + mat[2][1]*v[2],
mat[0][2]*v[2] + mat[1][2]*v[1] + mat[2][2]*v[2],
}
}

It should read (pay special attention to the first column):

func (mat *T) MulVec3(v *vec3.T) vec3.T {
return vec3.T{
mat[0][0]*v[0] + mat[1][0]*v[1] + mat[2][0]*v[2],
mat[0][1]*v[0] + mat[1][1]*v[1] + mat[2][1]*v[2],
mat[0][2]*v[0] + mat[1][2]*v[1] + mat[2][2]*v[2],
}
}

Looks like a cut-n-paste error, because TransformVec3 is correct.

ungerik commented 9 years ago

Thanks, fixed.

-Erik

On Fri, Feb 13, 2015 at 9:34 PM, Daniel Blezek notifications@github.com wrote:

Hi, This code in float64/mat3/mat3.go is broken:

func (mat _T) MulVec3(v *vec3.T) vec3.T { return vec3.T{ mat[0][0]_v[0] + mat[1][0]_v[1] + mat[2][0]_v[2], mat[0][1]_v[1] + mat[1][1]_v[1] + mat[2][1]_v[2], mat[0][2]_v[2] + mat[1][2]_v[1] + mat[2][2]_v[2], } }

It should read:



_T) MulVec3(v *vec3.T) vec3.T { return vec3.T{ mat[0][0]_v[0] + mat[1][0]*v[1]
- mat[2][0]_v[2],
  mat[0][1]_v[0] + mat[1][1]_v[1] + mat[2][1]
  *v[2], mat[0][2]_v[0] + mat[1][2]_v[1] + mat[2][2]_v[2],
  }
  }

Looks like a cut-n-paste error, because TransformVec3 is correct.

—
Reply to this email directly or view it on GitHub
https://github.com/ungerik/go3d/issues/12.

+43 650 58 33055 erik@erikunger.com Skype: ungerik http://erikunger.com http://github.com/ungerik http://twitter.com/ungerik http://facebook.com/ungerik http://www.linkedin.com/in/ungerik http://www.xing.com/profile/Erik_Unger2