-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#develop added deg-to-rad and rad-to-deg helper function
- Loading branch information
1 parent
8818fc8
commit a04b36e
Showing
6 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { degToRad } from './deg-to-rad'; | ||
|
||
describe('degToRad function', () => { | ||
it('should convert degrees to radians correctly', () => { | ||
expect(degToRad(180)).toBe(Math.PI); | ||
expect(degToRad(90)).toBe(Math.PI / 2); | ||
expect(degToRad(45)).toBe(Math.PI / 4); | ||
}); | ||
|
||
it('should handle zero correctly', () => { | ||
expect(degToRad(0)).toBe(0); | ||
}); | ||
|
||
it('should handle negative values correctly', () => { | ||
expect(degToRad(-180)).toBe(-Math.PI); | ||
expect(degToRad(-90)).toBe(-Math.PI / 2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Converts degrees to radians | ||
* @param deg - The angle in degrees | ||
* @returns The angle in radians | ||
*/ | ||
export function degToRad(deg: number): number { | ||
return deg * (Math.PI / 180); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { radToDeg } from './rad-to-deg'; | ||
|
||
describe('radToDeg function', () => { | ||
it('should convert radians to degrees correctly', () => { | ||
expect(radToDeg(Math.PI)).toBe(180); | ||
expect(radToDeg(Math.PI / 2)).toBe(90); | ||
expect(radToDeg(Math.PI / 4)).toBe(45); | ||
}); | ||
|
||
it('should handle zero correctly', () => { | ||
expect(radToDeg(0)).toBe(0); | ||
}); | ||
|
||
it('should handle negative values correctly', () => { | ||
expect(radToDeg(-Math.PI)).toBe(-180); | ||
expect(radToDeg(-Math.PI / 2)).toBe(-90); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Converts radians to degrees | ||
* @param rad - The angle in radians | ||
* @returns The angle in degrees | ||
*/ | ||
export function radToDeg(rad: number): number { | ||
return rad * (180 / Math.PI); | ||
} |