Skip to content

Add an algorithm to find length of an arc and area of the sector formed by an arc of a circle #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 8, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Maths/CircularArc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @function degreesToRadians
* @description convert from degrees to radians
* @param {Integer} angle in degrees
* @return {Integer} degrees * pi / 180
* @see https://en.wikipedia.org/wiki/Degree_(angle)
* @example degreesToRadians(45) = 0.7853981633974483
*/
function degreesToRadians (degrees) {
return degrees * Math.PI / 180
}

/**
* @function circularArcLength
* @description calculate the length of a circular arc
* @param {Integer} radius
* @param {Integer} degrees
* @returns {Integer} radius * angle_in_radians
* @see https://en.wikipedia.org/wiki/Circular_arc
* @example circularArcLength(3, 45) = 2.356194490192345
*/
function circularArcLength (radius, degrees) {
return radius * degreesToRadians(degrees)
}
/**
* @function circularArcArea
* @description calculate the area of the sector formed by an arc
* @param {Integer} radius
* @param {Integer} degrees
* @returns {Integer} 0.5 * r * r * angle_in_radians
* @see https://en.wikipedia.org/wiki/Circular_arc
* @example circularArcArea(3,45) = 3.5342917352885173
*/
function circularArcArea (radius, degrees) {
return Math.pow(radius, 2) * degreesToRadians(degrees) / 2
}

export {
circularArcLength,
circularArcArea
}