Skip to content

Commit

Permalink
feat: add getFocalRation() utility to optics module in @observerly/as…
Browse files Browse the repository at this point in the history
…trometry

feat: add getFocalRation() utility to optics module in @observerly/astrometry
  • Loading branch information
michealroberts committed Oct 10, 2024
1 parent 04be643 commit c3a299d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/optics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@

/*****************************************************************************************************************/

export {}
type FocalRatio = `f/${number}`

/*****************************************************************************************************************/

/**
*
* getFocalRatio()
*
* @param apertureWidth - the aperture of the optics
* @param focalLength - the focal length of the optics
* @returns the focal ratio as a string formatted in the standard focal ratio, e.g., f/x.
*/
export function getFocalRatio(apertureWidth: number, focalLength: number): FocalRatio {
// Check that the aperterure is a sensible number, e.g., > 0:
if (apertureWidth < 0) {
throw new Error(`Invalid focal ratio as aperture is negative`)
}

if (focalLength < 0) {
throw new Error(`Invalid focal ratio as focal length is negative`)
}

return `f/${focalLength / apertureWidth}`
}

/*****************************************************************************************************************/

0 comments on commit c3a299d

Please sign in to comment.