We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 26c1200 commit 59d62beCopy full SHA for 59d62be
1 file changed
src/geometry/Vector.js
@@ -62,14 +62,16 @@ module.exports = Vector;
62
* @method rotate
63
* @param {vector} vector
64
* @param {number} angle
65
- * @return {vector} A new vector rotated about (0, 0)
+ * @param {vector} [output]
66
+ * @return {vector} The vector rotated about (0, 0)
67
*/
- Vector.rotate = function(vector, angle) {
68
+ Vector.rotate = function(vector, angle, output) {
69
var cos = Math.cos(angle), sin = Math.sin(angle);
- return {
70
- x: vector.x * cos - vector.y * sin,
71
- y: vector.x * sin + vector.y * cos
72
- };
+ if (!output) output = {};
+ var x = vector.x * cos - vector.y * sin;
+ output.y = vector.x * sin + vector.y * cos;
73
+ output.x = x;
74
+ return output;
75
};
76
77
/**
0 commit comments