mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-02-04 13:14:42 +08:00
algorithm: find length of an arc and area of the sector formed by an arc of a circle (#1119)
* Add an algorithm to find length and area of an arc of a circle * Updated to follow Javascript Standard Style * Update CircularArc.js * Update CircularArc.js * Add tests * Followed Javascript standard style
This commit is contained in:
committed by
GitHub
parent
8461271fc8
commit
109e4a685b
19
Maths/test/CircularArc.test.js
Normal file
19
Maths/test/CircularArc.test.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { circularArcLength, circularArcArea } from '../CircularArc'
|
||||
|
||||
describe('circularArcLength', () => {
|
||||
it('with natural number', () => {
|
||||
const arcLengthOfOneThirty = circularArcLength(1, 30)
|
||||
const arcLengthOfThreeSixty = circularArcLength(3, 60)
|
||||
expect(arcLengthOfOneThirty).toBe(0.5235987755982988)
|
||||
expect(arcLengthOfThreeSixty).toBe(3.141592653589793)
|
||||
})
|
||||
})
|
||||
|
||||
describe('circularArcArea', () => {
|
||||
it('with natural number', () => {
|
||||
const arcAreaOfOneThirty = circularArcArea(1, 30)
|
||||
const arcAreaOfThreeSixty = circularArcArea(3, 60)
|
||||
expect(arcAreaOfOneThirty).toBe(0.2617993877991494)
|
||||
expect(arcAreaOfThreeSixty).toBe(4.71238898038469)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user