app.vector
, which will have methods for vector operations. Let's represent vectors themselves as objects with properties x
and y
, so the vector v = [ 3, -7.5 ] is declared as var v = { x: 3, y: -7.5 }
.
vector.add
as a function( vec1, vec2 )
that returns vec1 + vec2.vector.subtract
.vector.scalarMul
.vector.length
.vector.normalize
.vector.distance
.vector.dot
.app.vector.perp = function( vec ) { return { x: -vec.y, y: vec.x }; };What does it do? (Hint: What is the angle between v and perp(v)? Try plotting a few examples on graph paper.)
tar -czvf Gameplay_3_MyName.tgz Vector.js