hextris/math.js

10 lines
238 B
JavaScript
Raw Normal View History

2014-05-17 14:43:16 +00:00
function rotatePoint(x, y, theta) {
2014-05-17 15:03:11 +00:00
var thetaRad = theta * (Math.PI / 180);
2014-05-17 14:43:16 +00:00
var rotX = Math.cos(thetaRad) * x - Math.sin(thetaRad) * y;
var rotY = Math.sin(thetaRad) * x + Math.cos(thetaRad) * y;
return {
x: rotX,
y: rotY,
};
}