-
Notifications
You must be signed in to change notification settings - Fork 0
/
imaging_format.js
36 lines (29 loc) · 896 Bytes
/
imaging_format.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class ImagingFormat {
constructor(name, widthInMm, heightInMm) {
this.name = name;
this.widthInMm = widthInMm;
this.heightInMm = heightInMm;
this.commonFocalLengths = [];
}
setCommonFocalLengths(commonFocalLengths) {
this.commonFocalLengths = commonFocalLengths;
}
diagonalInMm() {
return Math.sqrt(this.widthInMm ** 2 + this.heightInMm ** 2);
}
normalFocalLength() {
return Math.round(this.diagonalInMm());
}
equivalentToFocalLengthInFormat(otherFocalLength, otherFormat) {
return otherFocalLength * this._diagonalRatioToFormat(otherFormat);
}
_longestSide() {
return Math.max(this.widthInMm, this.heightInMm);
}
_diagonalRatioToFormat(otherFormat) {
return this.diagonalInMm() / otherFormat.diagonalInMm();
}
_longestSideRatioToFormat(otherFormat) {
return this._longestSide() / otherFormat._longestSide();
}
}