Skip to content

Commit

Permalink
better checks for rotate (static function)
Browse files Browse the repository at this point in the history
  • Loading branch information
siv2r committed Jan 4, 2021
1 parent f25907b commit b5abddd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/math/p5.Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2162,18 +2162,17 @@ p5.Vector.mult = function mult(v, n, target) {
* @param {Number} angle
* @param {p5.Vector} [target] the vector to receive the result (Optional)
*/

p5.Vector.rotate = function rotate(v, a, target) {
if (!target) {
if (arguments.length === 2) {
target = v.copy();
if (arguments.length === 3) {
p5._friendlyError(
'The target parameter is undefined, it should be of type p5.Vector',
'p5.Vector.rotate'
);
}
} else {
} else if (target instanceof p5.Vector) {
target.set(v);
} else {
target = v.copy();
p5._friendlyError(
'The target parameter should be of type p5.Vector',
'p5.Vector.rotate'
);
}
target.rotate(a);
return target;
Expand Down

0 comments on commit b5abddd

Please sign in to comment.