Skip to content

Commit

Permalink
Merge pull request #75 from UrielCh/v3
Browse files Browse the repository at this point in the history
[BREAKING CHANGE] Convert project code to typescript
  • Loading branch information
piercus authored May 12, 2024
2 parents a7ced5c + 6e2dc17 commit 5376d99
Show file tree
Hide file tree
Showing 79 changed files with 6,309 additions and 6,379 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Node.js CI

on: [push]
on: [push, pull_request]

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ typings/

# dist is generated in the deployment process from src
dist/
cjs/
8 changes: 6 additions & 2 deletions demo/bike/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ module.exports = {
predicted = kf.predict({previousCorrected});
const {mean, covariance} = predicted;

const element = createGroupBoxes({mean, covariance, parent: img, className: 'predicted', color: 'blue'});
const element = createGroupBoxes({
mean, covariance, parent: img, className: 'predicted', color: 'blue',
});
els.push(element);

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

const element = createGroupBoxes({mean, covariance, parent: img, className: 'corrected', color: 'red'});
const element = createGroupBoxes({
mean, covariance, parent: img, className: 'corrected', color: 'red',
});
els.push(element);

return delayPromise(delay);
Expand Down
8 changes: 6 additions & 2 deletions demo/bouncing-ball/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ module.exports = {
predicted = kf.predict({previousCorrected});
const {mean, covariance} = predicted;

createGroupPoint({mean, covariance, parent: img, className: 'predicted', color: 'blue'});
createGroupPoint({
mean, covariance, parent: img, className: 'predicted', color: 'blue',
});

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

createGroupPoint({mean, covariance, parent: img, className: 'corrected', color: 'red'});
createGroupPoint({
mean, covariance, parent: img, className: 'corrected', color: 'red',
});

return delayPromise(delay);
}).bind(null, box, index));
Expand Down
2 changes: 1 addition & 1 deletion demo/shared/views/create-group-boxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function ({mean, covariance, color, parent, className, tag = 'd
color,
});
const arrowRotation = (-1 * Math.atan(mean[4][0] / mean[5][0]) * 180 / Math.PI) - 45;
const arrowScale = Math.sqrt((mean[4][0] ** 2) + (mean[5][0] ** 2));
const arrowScale = Math.hypot(mean[4][0], mean[5][0]);
createArrow({
className: 'arrow',
bbox: [
Expand Down
2 changes: 1 addition & 1 deletion demo/shared/views/create-group-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function ({mean, covariance, color, parent, className, tag = 'd
color,
});
const arrowRotation = (-1 * Math.atan(mean[2][0] / mean[3][0]) * 180 / Math.PI) - 45;
const arrowScale = Math.sqrt((mean[2][0] ** 2) + (mean[3][0] ** 2));
const arrowScale = Math.hypot(mean[2][0], mean[3][0]);
createArrow({
className: 'arrow',
bbox: [
Expand Down
21 changes: 0 additions & 21 deletions index.js

This file was deleted.

31 changes: 31 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as modelCollection from './lib/model-collection';
import * as defaultDynamicModels from './lib/dynamic';
import * as defaultObservationModels from './lib/observation';

function camelToDash(str: string) {
if (str === str.toLowerCase()) {
return str;
}
return str.replaceAll(/[A-Z]/g, m => '-' + m.toLowerCase());
}

Object.keys(defaultDynamicModels).forEach((k: string) => {

modelCollection.registerDynamic(camelToDash(k), defaultDynamicModels[k]);
});

Object.keys(defaultObservationModels).forEach((k: string) => {
modelCollection.registerObservation(camelToDash(k), defaultObservationModels[k]);
});

export * from './lib/model-collection';
export * from './lib/dynamic';
export * from './lib/observation';

export {default as KalmanFilter} from './lib/kalman-filter';
export {default as getCovariance} from './lib/utils/get-covariance';
export {default as State} from './lib/state';
export {default as checkCovariance} from './lib/utils/check-covariance';
export {default as correlationToCovariance} from './lib/utils/correlation-to-covariance';
export {default as covarianceToCorrelation} from './lib/utils/covariance-to-correlation';
export {default as projectObservation} from './lib/utils/project-observation';
Loading

0 comments on commit 5376d99

Please sign in to comment.