I'm attempting to implement the transformation matrix formula:

cos() -sin()

sin() cos()

In the following Javascript code where this.rot.cos = cos of the angle and this.rot.sin is sin of the angle.

var h1 = this.rot.cos * this.dimension.x, h2 = this.rot.sin * this.dimension.x, h3 = this.rot.cos * this.dimension.y, h4 = this.rot.sin * this.dimension.y; v = [ { x: h1 - h4, y: h2 + h3 }, { x: -(h1 - h4), y: h2 + h3 }, { x: -(h1 - h4), y: -(h2 + h3) }, { x: h1 - h4, y: -(h2 + h3) } ]; tankBattle.ctx.beginPath(); tankBattle.ctx.moveTo(v[0].x, v[0].y); tankBattle.ctx.lineTo(v[1].x, v[1].y); tankBattle.ctx.lineTo(v[2].x, v[2].y); tankBattle.ctx.lineTo(v[3].x, v[3].y); tankBattle.ctx.lineTo(v[0].x, v[0].y);

The shape I get moves in the same pattern as sin and cos waves and becomes 0 at certain degrees (90 and 270 I believe). Is there something I'm doing wrong to calculate the vertices here?