Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE Migration Typescript #72

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/
16 changes: 12 additions & 4 deletions demo/bike/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const {KalmanFilter} = kalmanFilter;// eslint-disable-line no-undef
/**
* @typedef {typeof import('../../index.d.ts')} kalmanFilter
*/
const { KalmanFilter } = /** @type {kalmanFilter} */ (kalmanFilter);// eslint-disable-line no-undef
const createElement = require('../shared/views/create-element');
const createGroupBoxes = require('../shared/views/create-group-boxes');
const noisyObservations = require('./observations.json').observations;
const kfOptions = require('./kf-options');

const kf = new KalmanFilter(kfOptions);
let predicted = kf.predict();

const img = document.querySelector('#bikes');// eslint-disable-line no-undef
if (!img)
throw Error('#bikes div is missing from the DOM')

// Create all the elements of the prediction or correction phase
const delay = 200;
Expand Down Expand Up @@ -41,7 +45,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 +73,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
16 changes: 12 additions & 4 deletions demo/bouncing-ball/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const {KalmanFilter} = kalmanFilter;// eslint-disable-line no-undef
/**
* @typedef {typeof import('../../index.d.ts')} kalmanFilter
*/
const { KalmanFilter } = /** @type {kalmanFilter} */ (kalmanFilter);// eslint-disable-line no-undef
const createElement = require('../shared/views/create-element');
const createGroupPoint = require('../shared/views/create-group-point');
const kfOptions = require('./kf-options.js');
const noisyObservations = require('./observations.json').observations;

const kf = new KalmanFilter(kfOptions);
let predicted = kf.predict();

const img = document.querySelector('#bouncing-ball');// eslint-disable-line no-undef
if (!img)
throw Error('#bouncing-ball div is missing from the DOM')

// Create all the elements of the prediction or correction phase
const delay = 200;
Expand All @@ -27,7 +31,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 +60,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/bouncing-ball/observations.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ground": {
y: 442
"y": 442
},
"observations": [
[
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
20 changes: 14 additions & 6 deletions docs/dist/bike.js

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions docs/dist/bouncing-ball.js

Large diffs are not rendered by default.

Loading