Skip to content

Commit 2fe8885

Browse files
authored
Merge pull request #76 from piercus/develop
Develop
2 parents a7ced5c + 5376d99 commit 2fe8885

File tree

79 files changed

+6309
-6379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+6309
-6379
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Node.js CI
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,4 @@ typings/
104104

105105
# dist is generated in the deployment process from src
106106
dist/
107+
cjs/

demo/bike/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ module.exports = {
4141
predicted = kf.predict({previousCorrected});
4242
const {mean, covariance} = predicted;
4343

44-
const element = createGroupBoxes({mean, covariance, parent: img, className: 'predicted', color: 'blue'});
44+
const element = createGroupBoxes({
45+
mean, covariance, parent: img, className: 'predicted', color: 'blue',
46+
});
4547
els.push(element);
4648

4749
return delayPromise(delay);
@@ -67,7 +69,9 @@ module.exports = {
6769
previousCorrected = kf.correct({predicted, observation: b});
6870
const {mean, covariance} = previousCorrected;
6971

70-
const element = createGroupBoxes({mean, covariance, parent: img, className: 'corrected', color: 'red'});
72+
const element = createGroupBoxes({
73+
mean, covariance, parent: img, className: 'corrected', color: 'red',
74+
});
7175
els.push(element);
7276

7377
return delayPromise(delay);

demo/bouncing-ball/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ module.exports = {
2727
predicted = kf.predict({previousCorrected});
2828
const {mean, covariance} = predicted;
2929

30-
createGroupPoint({mean, covariance, parent: img, className: 'predicted', color: 'blue'});
30+
createGroupPoint({
31+
mean, covariance, parent: img, className: 'predicted', color: 'blue',
32+
});
3133

3234
return delayPromise(delay);
3335
})
@@ -54,7 +56,9 @@ module.exports = {
5456
previousCorrected = kf.correct({predicted, observation: b});
5557
const {mean, covariance} = previousCorrected;
5658

57-
createGroupPoint({mean, covariance, parent: img, className: 'corrected', color: 'red'});
59+
createGroupPoint({
60+
mean, covariance, parent: img, className: 'corrected', color: 'red',
61+
});
5862

5963
return delayPromise(delay);
6064
}).bind(null, box, index));

demo/shared/views/create-group-boxes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = function ({mean, covariance, color, parent, className, tag = 'd
7373
color,
7474
});
7575
const arrowRotation = (-1 * Math.atan(mean[4][0] / mean[5][0]) * 180 / Math.PI) - 45;
76-
const arrowScale = Math.sqrt((mean[4][0] ** 2) + (mean[5][0] ** 2));
76+
const arrowScale = Math.hypot(mean[4][0], mean[5][0]);
7777
createArrow({
7878
className: 'arrow',
7979
bbox: [

demo/shared/views/create-group-point.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function ({mean, covariance, color, parent, className, tag = 'd
2828
color,
2929
});
3030
const arrowRotation = (-1 * Math.atan(mean[2][0] / mean[3][0]) * 180 / Math.PI) - 45;
31-
const arrowScale = Math.sqrt((mean[2][0] ** 2) + (mean[3][0] ** 2));
31+
const arrowScale = Math.hypot(mean[2][0], mean[3][0]);
3232
createArrow({
3333
className: 'arrow',
3434
bbox: [

index.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as modelCollection from './lib/model-collection';
2+
import * as defaultDynamicModels from './lib/dynamic';
3+
import * as defaultObservationModels from './lib/observation';
4+
5+
function camelToDash(str: string) {
6+
if (str === str.toLowerCase()) {
7+
return str;
8+
}
9+
return str.replaceAll(/[A-Z]/g, m => '-' + m.toLowerCase());
10+
}
11+
12+
Object.keys(defaultDynamicModels).forEach((k: string) => {
13+
14+
modelCollection.registerDynamic(camelToDash(k), defaultDynamicModels[k]);
15+
});
16+
17+
Object.keys(defaultObservationModels).forEach((k: string) => {
18+
modelCollection.registerObservation(camelToDash(k), defaultObservationModels[k]);
19+
});
20+
21+
export * from './lib/model-collection';
22+
export * from './lib/dynamic';
23+
export * from './lib/observation';
24+
25+
export {default as KalmanFilter} from './lib/kalman-filter';
26+
export {default as getCovariance} from './lib/utils/get-covariance';
27+
export {default as State} from './lib/state';
28+
export {default as checkCovariance} from './lib/utils/check-covariance';
29+
export {default as correlationToCovariance} from './lib/utils/correlation-to-covariance';
30+
export {default as covarianceToCorrelation} from './lib/utils/covariance-to-correlation';
31+
export {default as projectObservation} from './lib/utils/project-observation';

0 commit comments

Comments
 (0)