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:
Prashal Ruchiranga
2022-10-08 12:26:06 +05:30
committed by GitHub
parent 8461271fc8
commit 109e4a685b
2 changed files with 50 additions and 0 deletions

View 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)
})
})