@photivra/engine 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +23 -0
- package/LICENSE +201 -0
- package/NOTICE +9 -0
- package/README.md +235 -0
- package/dist/camera/field-of-view.d.ts +37 -0
- package/dist/camera/field-of-view.d.ts.map +1 -0
- package/dist/camera/field-of-view.js +47 -0
- package/dist/camera/field-of-view.js.map +1 -0
- package/dist/camera/projected-object-size.d.ts +34 -0
- package/dist/camera/projected-object-size.d.ts.map +1 -0
- package/dist/camera/projected-object-size.js +57 -0
- package/dist/camera/projected-object-size.js.map +1 -0
- package/dist/core/calculation-result.d.ts +125 -0
- package/dist/core/calculation-result.d.ts.map +1 -0
- package/dist/core/calculation-result.js +175 -0
- package/dist/core/calculation-result.js.map +1 -0
- package/dist/core/validation.d.ts +30 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/core/validation.js +45 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/exposure/exposure.d.ts +50 -0
- package/dist/exposure/exposure.d.ts.map +1 -0
- package/dist/exposure/exposure.js +62 -0
- package/dist/exposure/exposure.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/motion/projected-motion.d.ts +41 -0
- package/dist/motion/projected-motion.d.ts.map +1 -0
- package/dist/motion/projected-motion.js +84 -0
- package/dist/motion/projected-motion.js.map +1 -0
- package/dist/optics/aperture.d.ts +39 -0
- package/dist/optics/aperture.d.ts.map +1 -0
- package/dist/optics/aperture.js +62 -0
- package/dist/optics/aperture.js.map +1 -0
- package/dist/optics/circle-of-confusion.d.ts +23 -0
- package/dist/optics/circle-of-confusion.d.ts.map +1 -0
- package/dist/optics/circle-of-confusion.js +32 -0
- package/dist/optics/circle-of-confusion.js.map +1 -0
- package/dist/optics/depth-of-field.d.ts +53 -0
- package/dist/optics/depth-of-field.d.ts.map +1 -0
- package/dist/optics/depth-of-field.js +81 -0
- package/dist/optics/depth-of-field.js.map +1 -0
- package/dist/optics/diffraction.d.ts +26 -0
- package/dist/optics/diffraction.d.ts.map +1 -0
- package/dist/optics/diffraction.js +21 -0
- package/dist/optics/diffraction.js.map +1 -0
- package/dist/optics/thin-lens.d.ts +30 -0
- package/dist/optics/thin-lens.d.ts.map +1 -0
- package/dist/optics/thin-lens.js +33 -0
- package/dist/optics/thin-lens.js.map +1 -0
- package/dist/output/crop.d.ts +27 -0
- package/dist/output/crop.d.ts.map +1 -0
- package/dist/output/crop.js +26 -0
- package/dist/output/crop.js.map +1 -0
- package/dist/output/subject-framing-crop.d.ts +36 -0
- package/dist/output/subject-framing-crop.d.ts.map +1 -0
- package/dist/output/subject-framing-crop.js +42 -0
- package/dist/output/subject-framing-crop.js.map +1 -0
- package/dist/schema/camera.d.ts +34 -0
- package/dist/schema/camera.d.ts.map +1 -0
- package/dist/schema/camera.js +3 -0
- package/dist/schema/camera.js.map +1 -0
- package/dist/schema/scene.d.ts +69 -0
- package/dist/schema/scene.d.ts.map +1 -0
- package/dist/schema/scene.js +3 -0
- package/dist/schema/scene.js.map +1 -0
- package/dist/schema/validation.d.ts +25 -0
- package/dist/schema/validation.d.ts.map +1 -0
- package/dist/schema/validation.js +180 -0
- package/dist/schema/validation.js.map +1 -0
- package/dist/sensor/pixel-pitch.d.ts +21 -0
- package/dist/sensor/pixel-pitch.d.ts.map +1 -0
- package/dist/sensor/pixel-pitch.js +19 -0
- package/dist/sensor/pixel-pitch.js.map +1 -0
- package/dist/sensor/signal-noise.d.ts +37 -0
- package/dist/sensor/signal-noise.d.ts.map +1 -0
- package/dist/sensor/signal-noise.js +53 -0
- package/dist/sensor/signal-noise.js.map +1 -0
- package/dist/simulation/poc-simulation.d.ts +264 -0
- package/dist/simulation/poc-simulation.d.ts.map +1 -0
- package/dist/simulation/poc-simulation.js +449 -0
- package/dist/simulation/poc-simulation.js.map +1 -0
- package/dist/stabilization/camera-shake.d.ts +41 -0
- package/dist/stabilization/camera-shake.d.ts.map +1 -0
- package/dist/stabilization/camera-shake.js +79 -0
- package/dist/stabilization/camera-shake.js.map +1 -0
- package/docs/API_STYLE.md +65 -0
- package/docs/ARCHITECTURE.md +51 -0
- package/docs/MOTION_AND_SIGNAL.md +53 -0
- package/docs/PHYSICS_FOUNDATION.md +92 -0
- package/docs/POC_API.md +210 -0
- package/docs/PROVENANCE.md +87 -0
- package/docs/STABILIZATION.md +78 -0
- package/docs/USAGE.md +538 -0
- package/package.json +91 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scientific provenance labels used throughout the public API.
|
|
3
|
+
*/
|
|
4
|
+
export type ProvenanceKind = "calculated" | "calibrated" | "estimated" | "approximation";
|
|
5
|
+
/**
|
|
6
|
+
* Metadata describing how a numerical result was produced.
|
|
7
|
+
*/
|
|
8
|
+
export interface CalculationProvenance {
|
|
9
|
+
/** Classification of the result's scientific origin. */
|
|
10
|
+
kind: ProvenanceKind;
|
|
11
|
+
/** Stable identifier for the model or equation set. */
|
|
12
|
+
model: string;
|
|
13
|
+
/** Version of the model, independent of the package version. */
|
|
14
|
+
modelVersion: string;
|
|
15
|
+
/** Concise assumptions that materially affect interpretation. */
|
|
16
|
+
assumptions?: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Source category for a quantified uncertainty estimate.
|
|
20
|
+
*/
|
|
21
|
+
export type UncertaintySource = "measurement" | "model-approximation" | "calibration";
|
|
22
|
+
/**
|
|
23
|
+
* Optional confidence metadata for a quantified uncertainty estimate.
|
|
24
|
+
*
|
|
25
|
+
* A confidence level is only meaningful when the basis can be stated. It must
|
|
26
|
+
* not be used as a generic subjective confidence score.
|
|
27
|
+
*/
|
|
28
|
+
export interface UncertaintyConfidence {
|
|
29
|
+
/** Confidence/coverage level as a fraction in the interval (0, 1]. */
|
|
30
|
+
level: number;
|
|
31
|
+
/** Concise description of the statistical/empirical basis. */
|
|
32
|
+
basis: string;
|
|
33
|
+
}
|
|
34
|
+
interface UncertaintyEstimateBase {
|
|
35
|
+
/** JSON-style path to the affected result quantity, e.g. value.distanceM. */
|
|
36
|
+
quantityPath: string;
|
|
37
|
+
/** Physical/statistical origin of this uncertainty component. */
|
|
38
|
+
source: UncertaintySource;
|
|
39
|
+
/** Optional confidence/coverage metadata when scientifically meaningful. */
|
|
40
|
+
confidence?: UncertaintyConfidence;
|
|
41
|
+
/** Concise interpretation note, if needed. */
|
|
42
|
+
note?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Absolute symmetric uncertainty around a result quantity.
|
|
46
|
+
*/
|
|
47
|
+
export interface AbsoluteUncertaintyEstimate extends UncertaintyEstimateBase {
|
|
48
|
+
kind: "absolute";
|
|
49
|
+
/** Symmetric ± magnitude in the explicitly named unit. */
|
|
50
|
+
plusMinus: number;
|
|
51
|
+
/** Explicit unit such as mm, m, px, or "1" for dimensionless values. */
|
|
52
|
+
unit: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Relative symmetric uncertainty around a result quantity.
|
|
56
|
+
*/
|
|
57
|
+
export interface RelativeUncertaintyEstimate extends UncertaintyEstimateBase {
|
|
58
|
+
kind: "relative";
|
|
59
|
+
/** Symmetric ± fractional magnitude; 0.05 means ±5%. */
|
|
60
|
+
fraction: number;
|
|
61
|
+
}
|
|
62
|
+
export type UncertaintyEstimate = AbsoluteUncertaintyEstimate | RelativeUncertaintyEstimate;
|
|
63
|
+
/**
|
|
64
|
+
* Documented parameter range over which a model/calibration is considered
|
|
65
|
+
* valid. This is model applicability metadata, not a statistical interval.
|
|
66
|
+
*/
|
|
67
|
+
export interface CalculationValidRange {
|
|
68
|
+
/** JSON-style input/model parameter path, e.g. input.focusDistanceM. */
|
|
69
|
+
parameterPath: string;
|
|
70
|
+
/** Explicit unit such as m, mm, ISO, or "1" for dimensionless values. */
|
|
71
|
+
unit: string;
|
|
72
|
+
minimum?: number;
|
|
73
|
+
maximum?: number;
|
|
74
|
+
note?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Optional quality metadata for a calculation result.
|
|
78
|
+
*
|
|
79
|
+
* Components remain separate by default. Callers must not add, combine in
|
|
80
|
+
* quadrature, or otherwise collapse uncertainty components unless a
|
|
81
|
+
* scientifically justified composition method explicitly documents
|
|
82
|
+
* independence/correlation assumptions.
|
|
83
|
+
*/
|
|
84
|
+
export interface CalculationQuality {
|
|
85
|
+
uncertainty?: readonly UncertaintyEstimate[];
|
|
86
|
+
validRanges?: readonly CalculationValidRange[];
|
|
87
|
+
notes?: readonly string[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Standard result envelope for public scientific calculations.
|
|
91
|
+
*
|
|
92
|
+
* Deterministic analytical results remain lightweight: quality is omitted when
|
|
93
|
+
* there is no defensible uncertainty/accuracy metadata to report.
|
|
94
|
+
*
|
|
95
|
+
* @typeParam T Serializable value returned by the calculation.
|
|
96
|
+
*/
|
|
97
|
+
export interface CalculationResult<T> {
|
|
98
|
+
value: T;
|
|
99
|
+
provenance: CalculationProvenance;
|
|
100
|
+
quality?: CalculationQuality;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validates result-quality metadata before it enters a public result envelope.
|
|
104
|
+
*
|
|
105
|
+
* @param quality Optional calculation quality metadata.
|
|
106
|
+
*/
|
|
107
|
+
export declare function validateCalculationQuality(quality: CalculationQuality | undefined): void;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a deterministic calculated-result envelope.
|
|
110
|
+
*/
|
|
111
|
+
export declare function calculatedResult<T>(value: T, model: string, modelVersion: string, assumptions?: readonly string[], quality?: CalculationQuality): CalculationResult<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an approximation-result envelope.
|
|
114
|
+
*/
|
|
115
|
+
export declare function approximationResult<T>(value: T, model: string, modelVersion: string, assumptions: readonly string[], quality?: CalculationQuality): CalculationResult<T>;
|
|
116
|
+
/**
|
|
117
|
+
* Creates an estimated-result envelope with explicit quality metadata.
|
|
118
|
+
*/
|
|
119
|
+
export declare function estimatedResult<T>(value: T, model: string, modelVersion: string, assumptions: readonly string[], quality: CalculationQuality): CalculationResult<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Creates a calibrated-result envelope with explicit quality metadata.
|
|
122
|
+
*/
|
|
123
|
+
export declare function calibratedResult<T>(value: T, model: string, modelVersion: string, assumptions: readonly string[], quality: CalculationQuality): CalculationResult<T>;
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=calculation-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculation-result.d.ts","sourceRoot":"","sources":["../../src/core/calculation-result.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,wDAAwD;IACxD,IAAI,EAAE,cAAc,CAAC;IACrB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,aAAa,GACb,qBAAqB,GACrB,aAAa,CAAC;AAElB;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,uBAAuB;IAC/B,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAA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AE,SAAS,MAAM,EAAE,EAC/B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,iBAAiB,CAAC,CAAC,CAAC,CAWtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,CAAC,EAAE,kBAAkB,GAC3B,iBAAiB,CAAC,CAAC,CAAC,CAWtB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAAC,CAAC,CAAC,CAWtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAAC,CAAC,CAAC,CAWtB"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { InvalidScientificResultError } from "./validation.js";
|
|
3
|
+
function requireNonEmptyString(path, value) {
|
|
4
|
+
if (value.trim().length === 0) {
|
|
5
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path} must not be empty.`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function requireNonNegativeFinite(path, value) {
|
|
9
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
10
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path} must be finite and greater than or equal to zero.`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function validateConfidence(confidence, path) {
|
|
14
|
+
if (confidence === undefined) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!Number.isFinite(confidence.level) ||
|
|
18
|
+
confidence.level <= 0 ||
|
|
19
|
+
confidence.level > 1) {
|
|
20
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path}.level must be in (0, 1].`);
|
|
21
|
+
}
|
|
22
|
+
requireNonEmptyString(`${path}.basis`, confidence.basis);
|
|
23
|
+
}
|
|
24
|
+
function validateUncertaintyEstimate(estimate, index) {
|
|
25
|
+
const path = `uncertainty[${index}]`;
|
|
26
|
+
requireNonEmptyString(`${path}.quantityPath`, estimate.quantityPath);
|
|
27
|
+
validateConfidence(estimate.confidence, `${path}.confidence`);
|
|
28
|
+
if (estimate.note !== undefined) {
|
|
29
|
+
requireNonEmptyString(`${path}.note`, estimate.note);
|
|
30
|
+
}
|
|
31
|
+
if (estimate.kind === "absolute") {
|
|
32
|
+
requireNonNegativeFinite(`${path}.plusMinus`, estimate.plusMinus);
|
|
33
|
+
requireNonEmptyString(`${path}.unit`, estimate.unit);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
requireNonNegativeFinite(`${path}.fraction`, estimate.fraction);
|
|
37
|
+
}
|
|
38
|
+
function validateValidRange(range, index) {
|
|
39
|
+
const path = `validRanges[${index}]`;
|
|
40
|
+
requireNonEmptyString(`${path}.parameterPath`, range.parameterPath);
|
|
41
|
+
requireNonEmptyString(`${path}.unit`, range.unit);
|
|
42
|
+
if (range.minimum === undefined && range.maximum === undefined) {
|
|
43
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path} must include minimum or maximum.`);
|
|
44
|
+
}
|
|
45
|
+
if (range.minimum !== undefined && !Number.isFinite(range.minimum)) {
|
|
46
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path}.minimum must be finite.`);
|
|
47
|
+
}
|
|
48
|
+
if (range.maximum !== undefined && !Number.isFinite(range.maximum)) {
|
|
49
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path}.maximum must be finite.`);
|
|
50
|
+
}
|
|
51
|
+
if (range.minimum !== undefined &&
|
|
52
|
+
range.maximum !== undefined &&
|
|
53
|
+
range.minimum > range.maximum) {
|
|
54
|
+
throw new InvalidScientificResultError(`Calculation quality field ${path} minimum must not exceed maximum.`);
|
|
55
|
+
}
|
|
56
|
+
if (range.note !== undefined) {
|
|
57
|
+
requireNonEmptyString(`${path}.note`, range.note);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates result-quality metadata before it enters a public result envelope.
|
|
62
|
+
*
|
|
63
|
+
* @param quality Optional calculation quality metadata.
|
|
64
|
+
*/
|
|
65
|
+
export function validateCalculationQuality(quality) {
|
|
66
|
+
if (quality === undefined) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (quality.uncertainty !== undefined) {
|
|
70
|
+
if (quality.uncertainty.length === 0) {
|
|
71
|
+
throw new InvalidScientificResultError("Calculation quality uncertainty must be omitted rather than empty.");
|
|
72
|
+
}
|
|
73
|
+
quality.uncertainty.forEach(validateUncertaintyEstimate);
|
|
74
|
+
}
|
|
75
|
+
if (quality.validRanges !== undefined) {
|
|
76
|
+
if (quality.validRanges.length === 0) {
|
|
77
|
+
throw new InvalidScientificResultError("Calculation quality validRanges must be omitted rather than empty.");
|
|
78
|
+
}
|
|
79
|
+
quality.validRanges.forEach(validateValidRange);
|
|
80
|
+
}
|
|
81
|
+
if (quality.notes !== undefined) {
|
|
82
|
+
if (quality.notes.length === 0) {
|
|
83
|
+
throw new InvalidScientificResultError("Calculation quality notes must be omitted rather than empty.");
|
|
84
|
+
}
|
|
85
|
+
quality.notes.forEach((note, index) => {
|
|
86
|
+
requireNonEmptyString(`notes[${index}]`, note);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (quality.uncertainty === undefined &&
|
|
90
|
+
quality.validRanges === undefined &&
|
|
91
|
+
quality.notes === undefined) {
|
|
92
|
+
throw new InvalidScientificResultError("Calculation quality must contain uncertainty, validRanges, or notes.");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function assertFiniteNumbers(value, path, seen) {
|
|
96
|
+
if (typeof value === "number") {
|
|
97
|
+
if (!Number.isFinite(value)) {
|
|
98
|
+
throw new InvalidScientificResultError(`Calculation produced a non-finite number at ${path}.`);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (typeof value !== "object" || value === null) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (seen.has(value)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
seen.add(value);
|
|
109
|
+
if (Array.isArray(value)) {
|
|
110
|
+
value.forEach((entry, index) => {
|
|
111
|
+
assertFiniteNumbers(entry, `${path}[${index}]`, seen);
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
116
|
+
assertFiniteNumbers(entry, `${path}.${key}`, seen);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function assertFiniteCalculationValue(value) {
|
|
120
|
+
assertFiniteNumbers(value, "value", new WeakSet());
|
|
121
|
+
}
|
|
122
|
+
function createResult(value, provenance, quality) {
|
|
123
|
+
assertFiniteCalculationValue(value);
|
|
124
|
+
validateCalculationQuality(quality);
|
|
125
|
+
return {
|
|
126
|
+
value,
|
|
127
|
+
provenance,
|
|
128
|
+
...(quality === undefined ? {} : { quality })
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Creates a deterministic calculated-result envelope.
|
|
133
|
+
*/
|
|
134
|
+
export function calculatedResult(value, model, modelVersion, assumptions, quality) {
|
|
135
|
+
return createResult(value, {
|
|
136
|
+
kind: "calculated",
|
|
137
|
+
model,
|
|
138
|
+
modelVersion,
|
|
139
|
+
...(assumptions === undefined ? {} : { assumptions })
|
|
140
|
+
}, quality);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Creates an approximation-result envelope.
|
|
144
|
+
*/
|
|
145
|
+
export function approximationResult(value, model, modelVersion, assumptions, quality) {
|
|
146
|
+
return createResult(value, {
|
|
147
|
+
kind: "approximation",
|
|
148
|
+
model,
|
|
149
|
+
modelVersion,
|
|
150
|
+
assumptions
|
|
151
|
+
}, quality);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Creates an estimated-result envelope with explicit quality metadata.
|
|
155
|
+
*/
|
|
156
|
+
export function estimatedResult(value, model, modelVersion, assumptions, quality) {
|
|
157
|
+
return createResult(value, {
|
|
158
|
+
kind: "estimated",
|
|
159
|
+
model,
|
|
160
|
+
modelVersion,
|
|
161
|
+
assumptions
|
|
162
|
+
}, quality);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Creates a calibrated-result envelope with explicit quality metadata.
|
|
166
|
+
*/
|
|
167
|
+
export function calibratedResult(value, model, modelVersion, assumptions, quality) {
|
|
168
|
+
return createResult(value, {
|
|
169
|
+
kind: "calibrated",
|
|
170
|
+
model,
|
|
171
|
+
modelVersion,
|
|
172
|
+
assumptions
|
|
173
|
+
}, quality);
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=calculation-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculation-result.js","sourceRoot":"","sources":["../../src/core/calculation-result.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AA2H/D,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAa;IACxD,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,4BAA4B,CACpC,6BAA6B,IAAI,qBAAqB,CACvD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAY,EAAE,KAAa;IAC3D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IA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C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAQ,EACR,KAAa,EACb,YAAoB,EACpB,WAA+B,EAC/B,OAA4B;IAE5B,OAAO,YAAY,CACjB,KAAK,EACL;QACE,IAAI,EAAE,YAAY;QAClB,KAAK;QACL,YAAY;QACZ,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;KACtD,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAQ,EACR,KAAa,EACb,YAAoB,EACpB,WAA8B,EAC9B,OAA4B;IAE5B,OAAO,YAAY,CACjB,KAAK,EACL;QACE,IAAI,EAAE,eAAe;QACrB,KAAK;QACL,YAAY;QACZ,WAAW;KACZ,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAQ,EACR,KAAa,EACb,YAAoB,EACpB,WAA8B,EAC9B,OAA2B;IAE3B,OAAO,YAAY,CACjB,KAAK,EACL;QACE,IAAI,EAAE,WAAW;QACjB,KAAK;QACL,YAAY;QACZ,WAAW;KACZ,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAQ,EACR,KAAa,EACb,YAAoB,EACpB,WAA8B,EAC9B,OAA2B;IAE3B,OAAO,YAAY,CACjB,KAAK,EACL;QACE,IAAI,EAAE,YAAY;QAClB,KAAK;QACL,YAAY;QACZ,WAAW;KACZ,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when a public scientific calculation receives invalid input.
|
|
3
|
+
*/
|
|
4
|
+
export declare class InvalidScientificInputError extends RangeError {
|
|
5
|
+
readonly code = "INVALID_SCIENTIFIC_INPUT";
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when a scientific calculation would return a non-finite
|
|
10
|
+
* numeric value that is unsafe for JSON and downstream consumers.
|
|
11
|
+
*/
|
|
12
|
+
export declare class InvalidScientificResultError extends RangeError {
|
|
13
|
+
readonly code = "INVALID_SCIENTIFIC_RESULT";
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Requires a finite number greater than zero.
|
|
18
|
+
*
|
|
19
|
+
* @param name Public parameter name.
|
|
20
|
+
* @param value Value to validate.
|
|
21
|
+
*/
|
|
22
|
+
export declare function requirePositiveFinite(name: string, value: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Requires a positive safe integer.
|
|
25
|
+
*
|
|
26
|
+
* @param name Public parameter name.
|
|
27
|
+
* @param value Value to validate.
|
|
28
|
+
*/
|
|
29
|
+
export declare function requirePositiveInteger(name: string, value: number): void;
|
|
30
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,UAAU;IACzD,QAAQ,CAAC,IAAI,8BAA8B;gBAE/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,UAAU;IAC1D,QAAQ,CAAC,IAAI,+BAA+B;gBAEhC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMxE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a public scientific calculation receives invalid input.
|
|
4
|
+
*/
|
|
5
|
+
export class InvalidScientificInputError extends RangeError {
|
|
6
|
+
code = "INVALID_SCIENTIFIC_INPUT";
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "InvalidScientificInputError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when a scientific calculation would return a non-finite
|
|
14
|
+
* numeric value that is unsafe for JSON and downstream consumers.
|
|
15
|
+
*/
|
|
16
|
+
export class InvalidScientificResultError extends RangeError {
|
|
17
|
+
code = "INVALID_SCIENTIFIC_RESULT";
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "InvalidScientificResultError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Requires a finite number greater than zero.
|
|
25
|
+
*
|
|
26
|
+
* @param name Public parameter name.
|
|
27
|
+
* @param value Value to validate.
|
|
28
|
+
*/
|
|
29
|
+
export function requirePositiveFinite(name, value) {
|
|
30
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
31
|
+
throw new InvalidScientificInputError(`${name} must be a finite number greater than zero.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Requires a positive safe integer.
|
|
36
|
+
*
|
|
37
|
+
* @param name Public parameter name.
|
|
38
|
+
* @param value Value to validate.
|
|
39
|
+
*/
|
|
40
|
+
export function requirePositiveInteger(name, value) {
|
|
41
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
42
|
+
throw new InvalidScientificInputError(`${name} must be a positive safe integer.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/core/validation.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,UAAU;IAChD,IAAI,GAAG,0BAA0B,CAAC;IAE3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,UAAU;IACjD,IAAI,GAAG,2BAA2B,CAAC;IAE5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC/D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,2BAA2B,CACnC,GAAG,IAAI,6CAA6C,CACrD,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,KAAa;IAChE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,2BAA2B,CACnC,GAAG,IAAI,mCAAmC,CAC3C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type CalculationResult } from "../core/calculation-result.js";
|
|
2
|
+
export interface CalculateExposureValue100Input {
|
|
3
|
+
/** F-number. */
|
|
4
|
+
aperture: number;
|
|
5
|
+
/** Shutter duration in seconds. */
|
|
6
|
+
shutterSeconds: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Calculates EV100 from aperture and shutter duration.
|
|
10
|
+
*
|
|
11
|
+
* @param input Aperture and shutter duration.
|
|
12
|
+
* @returns EV100 value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateExposureValue100(input: CalculateExposureValue100Input): CalculationResult<number>;
|
|
15
|
+
export interface CalculateRelativeOpticalExposureInput {
|
|
16
|
+
aperture: number;
|
|
17
|
+
shutterSeconds: number;
|
|
18
|
+
referenceAperture: number;
|
|
19
|
+
referenceShutterSeconds: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RelativeOpticalExposure {
|
|
22
|
+
/** Relative light exposure at the image plane; 1 equals the reference. */
|
|
23
|
+
factor: number;
|
|
24
|
+
/** Difference from the reference in stops. Positive means more light exposure. */
|
|
25
|
+
stops: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compares image-plane optical exposure using the proportional relation
|
|
29
|
+
* shutterSeconds / aperture^2.
|
|
30
|
+
*
|
|
31
|
+
* This does not include scene light, lens transmission, vignetting, or sensor
|
|
32
|
+
* response and therefore must not be interpreted as a photon-count result.
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateRelativeOpticalExposure(input: CalculateRelativeOpticalExposureInput): CalculationResult<RelativeOpticalExposure>;
|
|
35
|
+
export interface CalculateEquivalentIsoInput {
|
|
36
|
+
baseIso: number;
|
|
37
|
+
baseAperture: number;
|
|
38
|
+
baseShutterSeconds: number;
|
|
39
|
+
aperture: number;
|
|
40
|
+
shutterSeconds: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the ISO/gain setting that preserves nominal rendered exposure
|
|
44
|
+
* after changing aperture and/or shutter, assuming all other factors remain
|
|
45
|
+
* constant.
|
|
46
|
+
*
|
|
47
|
+
* This is an exposure-compensation relation, not a sensor-noise model.
|
|
48
|
+
*/
|
|
49
|
+
export declare function calculateEquivalentIso(input: CalculateEquivalentIsoInput): CalculationResult<number>;
|
|
50
|
+
//# sourceMappingURL=exposure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposure.d.ts","sourceRoot":"","sources":["../../src/exposure/exposure.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAGvC,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,8BAA8B,GACpC,iBAAiB,CAAC,MAAM,CAAC,CAU3B;AAED,MAAM,WAAW,qCAAqC;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,qCAAqC,GAC3C,iBAAiB,CAAC,uBAAuB,CAAC,CA6B5C;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,2BAA2B,GACjC,iBAAiB,CAAC,MAAM,CAAC,CAuB3B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { calculatedResult } from "../core/calculation-result.js";
|
|
3
|
+
import { requirePositiveFinite } from "../core/validation.js";
|
|
4
|
+
/**
|
|
5
|
+
* Calculates EV100 from aperture and shutter duration.
|
|
6
|
+
*
|
|
7
|
+
* @param input Aperture and shutter duration.
|
|
8
|
+
* @returns EV100 value.
|
|
9
|
+
*/
|
|
10
|
+
export function calculateExposureValue100(input) {
|
|
11
|
+
requirePositiveFinite("aperture", input.aperture);
|
|
12
|
+
requirePositiveFinite("shutterSeconds", input.shutterSeconds);
|
|
13
|
+
return calculatedResult(Math.log2((input.aperture * input.aperture) / input.shutterSeconds), "exposure-value-100", "1.0.0", ["Lens transmission (T-stop) is not modeled"]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compares image-plane optical exposure using the proportional relation
|
|
17
|
+
* shutterSeconds / aperture^2.
|
|
18
|
+
*
|
|
19
|
+
* This does not include scene light, lens transmission, vignetting, or sensor
|
|
20
|
+
* response and therefore must not be interpreted as a photon-count result.
|
|
21
|
+
*/
|
|
22
|
+
export function calculateRelativeOpticalExposure(input) {
|
|
23
|
+
requirePositiveFinite("aperture", input.aperture);
|
|
24
|
+
requirePositiveFinite("shutterSeconds", input.shutterSeconds);
|
|
25
|
+
requirePositiveFinite("referenceAperture", input.referenceAperture);
|
|
26
|
+
requirePositiveFinite("referenceShutterSeconds", input.referenceShutterSeconds);
|
|
27
|
+
const current = input.shutterSeconds / (input.aperture * input.aperture);
|
|
28
|
+
const reference = input.referenceShutterSeconds /
|
|
29
|
+
(input.referenceAperture * input.referenceAperture);
|
|
30
|
+
const factor = current / reference;
|
|
31
|
+
return calculatedResult({
|
|
32
|
+
factor,
|
|
33
|
+
stops: Math.log2(factor)
|
|
34
|
+
}, "relative-optical-exposure", "1.0.0", [
|
|
35
|
+
"Constant scene illumination",
|
|
36
|
+
"Lens transmission is not modeled",
|
|
37
|
+
"Sensor response is not modeled"
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the ISO/gain setting that preserves nominal rendered exposure
|
|
42
|
+
* after changing aperture and/or shutter, assuming all other factors remain
|
|
43
|
+
* constant.
|
|
44
|
+
*
|
|
45
|
+
* This is an exposure-compensation relation, not a sensor-noise model.
|
|
46
|
+
*/
|
|
47
|
+
export function calculateEquivalentIso(input) {
|
|
48
|
+
requirePositiveFinite("baseIso", input.baseIso);
|
|
49
|
+
requirePositiveFinite("baseAperture", input.baseAperture);
|
|
50
|
+
requirePositiveFinite("baseShutterSeconds", input.baseShutterSeconds);
|
|
51
|
+
requirePositiveFinite("aperture", input.aperture);
|
|
52
|
+
requirePositiveFinite("shutterSeconds", input.shutterSeconds);
|
|
53
|
+
const baseLight = input.baseShutterSeconds /
|
|
54
|
+
(input.baseAperture * input.baseAperture);
|
|
55
|
+
const newLight = input.shutterSeconds / (input.aperture * input.aperture);
|
|
56
|
+
return calculatedResult(input.baseIso * (baseLight / newLight), "equivalent-iso-compensation", "1.0.0", [
|
|
57
|
+
"Constant scene illumination",
|
|
58
|
+
"ISO is treated as gain/brightness compensation, not photon creation",
|
|
59
|
+
"Lens transmission and sensor-specific gain behavior are not modeled"
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=exposure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposure.js","sourceRoot":"","sources":["../../src/exposure/exposure.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EACL,gBAAgB,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAS9D;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAqC;IAErC,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClD,qBAAqB,CAAC,gBAAgB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE9D,OAAO,gBAAgB,CACrB,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,GA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B,CAAC,gBAAgB,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAE9D,MAAM,SAAS,GACb,KAAK,CAAC,kBAAkB;QACxB,CAAC,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,QAAQ,GACZ,KAAK,CAAC,cAAc,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE3D,OAAO,gBAAgB,CACrB,KAAK,CAAC,OAAO,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC,EACtC,6BAA6B,EAC7B,OAAO,EACP;QACE,6BAA6B;QAC7B,qEAAqE;QACrE,qEAAqE;KACtE,CACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Current public API contract version for the Photivra engine.
|
|
3
|
+
*
|
|
4
|
+
* This constant is intentionally independent of the package version so
|
|
5
|
+
* schema/API compatibility can be discussed explicitly.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ENGINE_API_VERSION: "0.17.0";
|
|
8
|
+
export { approximationResult, calibratedResult, calculatedResult, estimatedResult, validateCalculationQuality, type AbsoluteUncertaintyEstimate, type CalculationProvenance, type CalculationQuality, type CalculationResult, type CalculationValidRange, type ProvenanceKind, type RelativeUncertaintyEstimate, type UncertaintyConfidence, type UncertaintyEstimate, type UncertaintySource } from "./core/calculation-result.js";
|
|
9
|
+
export { InvalidScientificInputError, InvalidScientificResultError } from "./core/validation.js";
|
|
10
|
+
export { calculateFieldOfView, type CalculateFieldOfViewInput, type FieldOfView } from "./camera/field-of-view.js";
|
|
11
|
+
export { calculateProjectedObjectSize, type CalculateProjectedObjectSizeInput, type ProjectedObjectSize } from "./camera/projected-object-size.js";
|
|
12
|
+
export { calculatePixelPitch, type CalculatePixelPitchInput, type PixelPitch } from "./sensor/pixel-pitch.js";
|
|
13
|
+
export { calculateCenteredCrop, type CalculateCenteredCropInput, type CenteredCrop } from "./output/crop.js";
|
|
14
|
+
export { calculateSubjectFramingCrop, type CalculateSubjectFramingCropInput, type SubjectFramingCrop } from "./output/subject-framing-crop.js";
|
|
15
|
+
export { calculateIdealApertureGeometry, type ApertureVertex, type CalculateIdealApertureInput, type IdealApertureGeometry } from "./optics/aperture.js";
|
|
16
|
+
export { calculateAiryDisk, type AiryDisk, type CalculateAiryDiskInput } from "./optics/diffraction.js";
|
|
17
|
+
export { estimateEquivalentViewingCircleOfConfusion, type EquivalentViewingCircleOfConfusion, type EstimateEquivalentViewingCircleOfConfusionInput } from "./optics/circle-of-confusion.js";
|
|
18
|
+
export { calculateThinLensImageDistance, type CalculateThinLensImageDistanceInput, type ThinLensImageDistance } from "./optics/thin-lens.js";
|
|
19
|
+
export { calculateDefocusCircle, calculateDepthOfField, type CalculateDefocusCircleInput, type CalculateDepthOfFieldInput, type DefocusCircle, type DepthOfField } from "./optics/depth-of-field.js";
|
|
20
|
+
export type { CameraConfiguration, CameraSupport, ExposureConfiguration, FocusConfiguration, LensConfiguration, SensorConfiguration, StabilizationConfiguration } from "./schema/camera.js";
|
|
21
|
+
export type { SceneCapability, SceneDefinition, SceneMotion, SceneObject, SceneRadiometry, Vector3 } from "./schema/scene.js";
|
|
22
|
+
export { calculateProjectedMotionBlur, type CalculateProjectedMotionBlurInput, type ProjectedMotionBlur } from "./motion/projected-motion.js";
|
|
23
|
+
export { calculateEquivalentIso, calculateExposureValue100, calculateRelativeOpticalExposure, type CalculateEquivalentIsoInput, type CalculateExposureValue100Input, type CalculateRelativeOpticalExposureInput, type RelativeOpticalExposure } from "./exposure/exposure.js";
|
|
24
|
+
export { estimateCameraShakeBlur, type CameraShakeBlurSample, type CameraShakeEstimate, type EstimateCameraShakeBlurInput } from "./stabilization/camera-shake.js";
|
|
25
|
+
export { calculatePhotoelectrons, calculateSignalToNoise, type CalculatePhotoelectronsInput, type CalculateSignalToNoiseInput, type SignalToNoise } from "./sensor/signal-noise.js";
|
|
26
|
+
export { simulatePocCamera, type PocSimulationRequest, type PocSimulationResponse } from "./simulation/poc-simulation.js";
|
|
27
|
+
export { InvalidConfigurationError, parseCameraConfiguration, parseSceneDefinition } from "./schema/validation.js";
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAG,QAAiB,CAAC;AAEpD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,4BAA4B,EAC5B,KAAK,iCAAiC,EACtC,KAAK,mBAAmB,EACzB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,2BAA2B,EAC3B,KAAK,gCAAgC,EACrC,KAAK,kBAAkB,EACxB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,8BAA8B,EAC9B,KAAK,cAAc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A0B,CAAC;AAGlC,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Current public API contract version for the Photivra engine.
|
|
4
|
+
*
|
|
5
|
+
* This constant is intentionally independent of the package version so
|
|
6
|
+
* schema/API compatibility can be discussed explicitly.
|
|
7
|
+
*/
|
|
8
|
+
export const ENGINE_API_VERSION = "0.17.0";
|
|
9
|
+
export { approximationResult, calibratedResult, calculatedResult, estimatedResult, validateCalculationQuality } from "./core/calculation-result.js";
|
|
10
|
+
export { InvalidScientificInputError, InvalidScientificResultError } from "./core/validation.js";
|
|
11
|
+
export { calculateFieldOfView } from "./camera/field-of-view.js";
|
|
12
|
+
export { calculateProjectedObjectSize } from "./camera/projected-object-size.js";
|
|
13
|
+
export { calculatePixelPitch } from "./sensor/pixel-pitch.js";
|
|
14
|
+
export { calculateCenteredCrop } from "./output/crop.js";
|
|
15
|
+
export { calculateSubjectFramingCrop } from "./output/subject-framing-crop.js";
|
|
16
|
+
export { calculateIdealApertureGeometry } from "./optics/aperture.js";
|
|
17
|
+
export { calculateAiryDisk } from "./optics/diffraction.js";
|
|
18
|
+
export { estimateEquivalentViewingCircleOfConfusion } from "./optics/circle-of-confusion.js";
|
|
19
|
+
export { calculateThinLensImageDistance } from "./optics/thin-lens.js";
|
|
20
|
+
export { calculateDefocusCircle, calculateDepthOfField } from "./optics/depth-of-field.js";
|
|
21
|
+
export { calculateProjectedMotionBlur } from "./motion/projected-motion.js";
|
|
22
|
+
export { calculateEquivalentIso, calculateExposureValue100, calculateRelativeOpticalExposure } from "./exposure/exposure.js";
|
|
23
|
+
export { estimateCameraShakeBlur } from "./stabilization/camera-shake.js";
|
|
24
|
+
export { calculatePhotoelectrons, calculateSignalToNoise } from "./sensor/signal-noise.js";
|
|
25
|
+
export { simulatePocCamera } from "./simulation/poc-simulation.js";
|
|
26
|
+
export { InvalidConfigurationError, parseCameraConfiguration, parseSceneDefinition } from "./schema/validation.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAiB,CAAC;AAEpD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAW3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EAGrB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,4BAA4B,EAG7B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,mBAAmB,EAGpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EAGtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,2BAA2B,EAG5B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,8BAA8B,EAI/B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EAGlB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,0CAA0C,EAG3C,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,8BAA8B,EAG/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EAKtB,MAAM,4BAA4B,CAAC;AAsBpC,OAAO,EACL,4BAA4B,EAG7B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,gCAAgC,EAKjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,uBAAuB,EAIxB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EAIvB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,iBAAiB,EAGlB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type CalculationResult } from "../core/calculation-result.js";
|
|
2
|
+
import type { Vector3 } from "../schema/scene.js";
|
|
3
|
+
export interface CalculateProjectedMotionBlurInput {
|
|
4
|
+
/** Lens focal length in millimetres. */
|
|
5
|
+
focalLengthMm: number;
|
|
6
|
+
/** Shutter-open duration in seconds. */
|
|
7
|
+
shutterSeconds: number;
|
|
8
|
+
/** Object position at shutter open, in camera-relative metres. +z is away from the camera. */
|
|
9
|
+
positionM: Vector3;
|
|
10
|
+
/** Constant world-space velocity during the exposure, in metres per second. */
|
|
11
|
+
velocityMps: Vector3;
|
|
12
|
+
/** Optional focus distance in metres for focus-aware sensor-plane projection. */
|
|
13
|
+
focusDistanceM?: number;
|
|
14
|
+
/** Optional sensor pixel pitch in micrometres for pixel-domain blur reporting. */
|
|
15
|
+
pixelPitchMicrometers?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ProjectedMotionBlur {
|
|
18
|
+
deltaXMm: number;
|
|
19
|
+
deltaYMm: number;
|
|
20
|
+
distanceMm: number;
|
|
21
|
+
projectionDistanceMm: number;
|
|
22
|
+
distancePixels?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Calculates sensor-plane motion during an exposure using ideal rectilinear
|
|
26
|
+
* projection and constant linear object velocity.
|
|
27
|
+
*
|
|
28
|
+
* Without focusDistanceM, nominal focal length is the backwards-compatible
|
|
29
|
+
* pinhole projection distance. With focusDistanceM, the selected thin-lens
|
|
30
|
+
* sensor-plane image distance is used.
|
|
31
|
+
*
|
|
32
|
+
* The calculation projects the object's shutter-open and shutter-close
|
|
33
|
+
* positions onto the image plane and measures the displacement between them.
|
|
34
|
+
* It therefore handles lateral and depth-direction motion without relying on a
|
|
35
|
+
* generic "subject speed" category.
|
|
36
|
+
*
|
|
37
|
+
* @param input Camera, exposure, object-position, and velocity inputs.
|
|
38
|
+
* @returns Projected sensor-plane displacement.
|
|
39
|
+
*/
|
|
40
|
+
export declare function calculateProjectedMotionBlur(input: CalculateProjectedMotionBlurInput): CalculationResult<ProjectedMotionBlur>;
|
|
41
|
+
//# sourceMappingURL=projected-motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projected-motion.d.ts","sourceRoot":"","sources":["../../src/motion/projected-motion.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAMvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,WAAW,iCAAiC;IAChD,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,8FAA8F;IAC9F,SAAS,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,WAAW,EAAE,OAAO,CAAC;IACrB,iFAAiF;IACjF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAYD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,iCAAiC,GACvC,iBAAiB,CAAC,mBAAmB,CAAC,CAkFxC"}
|