From 537e860cf81c64428720d8ec9b4f8462be566a12 Mon Sep 17 00:00:00 2001 From: vansh kabra Date: Mon, 3 Mar 2025 23:22:40 +0530 Subject: [PATCH] Fix: Update sin(), cos(), and tan() docs to respect angleMode() & clarify arc() behavior. --- src/core/shape/2d_primitives.js | 5 ++++- src/math/trigonometry.js | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/core/shape/2d_primitives.js b/src/core/shape/2d_primitives.js index f916339514..b1f7d66ae5 100644 --- a/src/core/shape/2d_primitives.js +++ b/src/core/shape/2d_primitives.js @@ -110,7 +110,10 @@ p5.prototype._normalizeArcAngles = ( * * The fifth and sixth parameters, `start` and `stop`, set the angles * between which to draw the arc. Arcs are always drawn clockwise from - * `start` to `stop`. Angles are always given in radians. + * `start` to `stop`. The fifth and sixth parameters, start and stop, set the + * angles between which to draw the arc. Arcs are always drawn clockwise from + * start to stop. By default, angles are given in radians, but if angleMode + * (DEGREES) is set, the function interprets the values in degrees. * * The seventh parameter, `mode`, is optional. It determines the arc's fill * style. The fill modes are a semi-circle (`OPEN`), a closed semi-circle diff --git a/src/math/trigonometry.js b/src/math/trigonometry.js index cb2af7c709..788dbfb1ff 100644 --- a/src/math/trigonometry.js +++ b/src/math/trigonometry.js @@ -283,10 +283,12 @@ p5.prototype.atan2 = function(y, x) { * * `cos()` is useful for many geometric tasks in creative coding. The values * returned oscillate between -1 and 1 as the input angle increases. `cos()` - * takes into account the current angleMode(). + * calculates the cosine of an angle, using radians by default, or according to + * if angleMode() setting (RADIANS or DEGREES). * * @method cos - * @param {Number} angle the angle in radians unless specified by angleMode(). + * @param {Number} angle the angle, in radians by default, or according to + * if angleMode() setting (RADIANS or DEGREES). * @return {Number} cosine of the angle. * * @example @@ -363,10 +365,12 @@ p5.prototype.cos = function(angle) { * * `sin()` is useful for many geometric tasks in creative coding. The values * returned oscillate between -1 and 1 as the input angle increases. `sin()` - * takes into account the current angleMode(). + * calculates the sine of an angle, using radians by default, or according to + * if angleMode() setting (RADIANS or DEGREES). * * @method sin - * @param {Number} angle the angle in radians unless specified by angleMode(). + * @param {Number} angle the angle, in radians by default, or according to + * if angleMode() setting (RADIANS or DEGREES). * @return {Number} sine of the angle. * * @example @@ -443,11 +447,13 @@ p5.prototype.sin = function(angle) { * * `tan()` is useful for many geometric tasks in creative coding. The values * returned range from -Infinity to Infinity and repeat periodically as the - * input angle increases. `tan()` takes into account the current - * angleMode(). + * input angle increases. `tan()` calculates the tan of an angle, using radians + * by default, or according to + * if angleMode() setting (RADIANS or DEGREES). * * @method tan - * @param {Number} angle the angle in radians unless specified by angleMode(). + * @param {Number} angle the angle, in radians by default, or according to + * if angleMode() setting (RADIANS or DEGREES). * @return {Number} tangent of the angle. * * @example