File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 66
77/*****************************************************************************************************************/
88
9- export { }
9+ type FocalRatio = `f/${number } `
10+
11+ /*****************************************************************************************************************/
12+
13+ /**
14+ *
15+ * getFocalRatio()
16+ *
17+ * @param apertureWidth - the aperture of the optics
18+ * @param focalLength - the focal length of the optics
19+ * @returns the focal ratio as a string formatted in the standard focal ratio, e.g., f/x.
20+ */
21+ export function getFocalRatio ( apertureWidth : number , focalLength : number ) : FocalRatio {
22+ // Check that the aperterure is a sensible number, e.g., > 0:
23+ if ( apertureWidth < 0 ) {
24+ throw new Error ( `Invalid focal ratio as aperture is negative` )
25+ }
26+
27+ if ( focalLength < 0 ) {
28+ throw new Error ( `Invalid focal ratio as focal length is negative` )
29+ }
30+
31+ return `f/${ focalLength / apertureWidth } `
32+ }
1033
1134/*****************************************************************************************************************/
You can’t perform that action at this time.
0 commit comments