Skip to content

Commit

Permalink
Added tests (and fix) for vec.transform()
Browse files Browse the repository at this point in the history
  • Loading branch information
slaskis committed Nov 27, 2012
1 parent 70fe662 commit 5feee7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -190,7 +190,7 @@ var vec = module.exports = {
// m = mat
transform: function(a,m,c){
c = c || vec.make()
var x=a[0], y=[1];
var x=a[0], y=a[1];
c[0] = m[0]*x + m[3]*y + m[2]
c[1] = m[1]*x + m[4]*y + m[5]
return c;
Expand Down
23 changes: 20 additions & 3 deletions test.js
Expand Up @@ -609,12 +609,29 @@ describe('geom',function(){
vec.add(o,t).should.not.eql(a)
vec.add(o,t).should.eql([15,15])
})

after(function(){
vec.free(a)
vec.free(m)
})
})

describe('transform',function(){
it('transform(mat.rotate(Math.PI))')
it('transform(mat.scale(5,0))')
it('transform(mat.translate(0,5))')
var a = vec.make(15,0)

it('transform(a,mat.rotate(Math.PI))',function(){
vec.transform(a,mat.rotate(Math.PI)).should.eql(vec.rot(a,Math.PI))
})
it('transform(a,mat.scale(5,0))',function(){
vec.transform(a,mat.scale(5,0)).should.eql(vec.mul(a,[5,0]))
})
it('transform(a,mat.translate(0,5))',function(){
vec.transform(a,mat.translate(-5,10)).should.eql(vec.add(a,[-5,10]))
})

after(function(){
vec.free(a)
})
})

})
Expand Down

0 comments on commit 5feee7c

Please sign in to comment.