Skip to content

Commit bcb5c8d

Browse files
committed
feat: remove linalgebra and use simple-linalg instead
BREAKING CHANGE: the linalgebra is not exposed anymore
1 parent ffeed39 commit bcb5c8d

Some content is hidden

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

43 files changed

+141
-322
lines changed

docs/dist/bouncing-ball.js

Lines changed: 10 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/kalman-filter.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 83 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,84 @@
55
<title>Kalman Filter Demo on Bike Image</title>
66
<link rel="stylesheet" type="text/css" href="./style.css">
77

8+
<!-- Add a header section with the demo title and description -->
9+
<header>
10+
<h1>Kalman Filter Demo</h1>
11+
<p>This demo shows how a Kalman filter can be used to estimate the position of a moving object over time, even in the presence of noise and uncertainty.</p>
12+
</header>
13+
14+
<!-- Use CSS Grid to create a flexible layout -->
15+
<style>
16+
body {
17+
display: grid;
18+
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
19+
grid-gap: 1rem;
20+
}
21+
.img, .controls {
22+
width: 100%;
23+
margin: auto;
24+
}
25+
h1, p {
26+
text-align: center;
27+
}
28+
img {
29+
max-width: 100%;
30+
height: auto;
31+
display: block;
32+
margin: 0 auto;
33+
}
34+
.top-right {
35+
position: absolute;
36+
top: 0;
37+
right: 0;
38+
margin: 1rem;
39+
z-index: 1;
40+
font-size: 0.8rem;
41+
}
42+
.top-right h4 {
43+
margin: 0;
44+
font-weight: normal;
45+
}
46+
.controls {
47+
display: flex;
48+
flex-wrap: wrap;
49+
justify-content: center;
50+
align-items: center;
51+
padding: 1rem;
52+
background-color: #f2f2f2;
53+
}
54+
.controls input[type="button"] {
55+
background-color: #4CAF50;
56+
color: white;
57+
border: none;
58+
padding: 0.5rem 1rem;
59+
margin: 0.5rem;
60+
cursor: pointer;
61+
border-radius: 4px;
62+
transition: background-color 0.3s ease;
63+
}
64+
.controls input[type="button"]:hover {
65+
background-color: #3e8e41;
66+
}
67+
.controls label {
68+
font-size: 0.8rem;
69+
margin-left: 0.5rem;
70+
}
71+
#status {
72+
text-align:center;
73+
font-size: 0.8rem;
74+
margin-top: 1rem;
75+
}
76+
</style>
877

978
</head>
1079
<body>
1180
<div class="img" id='bikes'>
1281
<img src="./bike.gif">
1382
<div class="top-right" id='legend'>
14-
<h4 style="color: blue;"> Prediction
15-
</h4>
16-
<h4 style="color: white;"> Observation
17-
</h4>
18-
<h4 style="color: red;"> Correction
19-
</h4>
83+
<h4 style="color: blue;">Prediction</h4>
84+
<h4 style="color: white;">Observation</h4>
85+
<h4 style="color: red;">Correction</h4>
2086
</div>
2187
</div>
2288
<div class="controls" id='controls'>
@@ -27,21 +93,20 @@ <h4 style="color: red;"> Correction
2793
<input id="clickMe" type="button" value="Show/Hide Corrections" onclick="showHide('corrected');" />
2894

2995
<input type="checkbox" id="speedVectors" onclick="showHide('speedVectors');">
30-
<label for="checkbox1"> Speed Vectors </label>
96+
<label for="checkbox1">Speed Vectors</label>
3197
<input type="checkbox" id="Variances" onclick="showHide('variances');" checked="checked">
32-
<label for="checkbox1"> Variances </label>
98+
<label for="checkbox2">Variances</label>
3399
<input type="checkbox" id="Covariances" onclick="showHide('covariances');">
34-
<label for="checkbox1"> Covariances </label>
100+
<label for="checkbox3">Covariances</label>
35101
</div>
36102

37-
103+
<!-- Add a div to display status messages -->
104+
<div id="status"></div>
38105
</body>
39106
<script src="dist/kalman-filter.js"></script>
40107
<script src="dist/bike.js"></script>
41108

42109
<script>
43-
//
44-
// const btn = document.querySelector('button');
45110
const status = {
46111
'predicted': false,
47112
'observation': true,
@@ -72,7 +137,12 @@ <h4 style="color: red;"> Correction
72137
const run = function(){
73138
require('bike').run()
74139
}
140+
141+
// Add event listener to display status messages when the user clicks the "Run Kalman Filter" button
142+
document.querySelector('#clickMe').addEventListener('click', function() {
143+
document.querySelector('#status').innerHTML = 'Running Kalman Filter...';
144+
});
75145
</script>
76146

77147

78-
</html>
148+
</html>

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ module.exports = {
1010
State: require('./lib/state'),
1111
checkCovariance: require('./lib/utils/check-covariance'),
1212
correlationToCovariance: require('./lib/utils/correlation-to-covariance'),
13-
covarianceToCorrelation: require('./lib/utils/covariance-to-correlation'),
14-
linalgebra: require('./lib/linalgebra')
13+
covarianceToCorrelation: require('./lib/utils/covariance-to-correlation')
1514
};

lib/core-kalman-filter.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
const matMul = require('../lib/linalgebra/mat-mul.js');
2-
const transpose = require('../lib/linalgebra/transpose.js');
3-
const add = require('../lib/linalgebra/add.js');
4-
const invert = require('../lib/linalgebra/invert.js');
5-
const sub = require('../lib/linalgebra/sub.js');
6-
const getIdentity = require('../lib/linalgebra/identity.js');
1+
const {matMul, transpose, add, invert, subtract: sub, identity: getIdentity} = require('simple-linalg');
2+
73
const State = require('./state.js');
84
const checkMatrix = require('./utils/check-matrix.js');
95
/**

lib/dynamic/constant-acceleration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const identity = require('../linalgebra/identity.js');
1+
const {identity} = require('simple-linalg');
22

33
/**
44
*Creates a dynamic model, following constant acceleration model with respect with the dimensions provided in the observation parameters

lib/dynamic/constant-position.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const identity = require('../linalgebra/identity.js');
1+
const {identity} = require('simple-linalg');
22
/**
33
*Creates a dynamic model, following constant position model with respect with the dimensions provided in the observation parameters
44
* @param {DynamicConfig} dynamic

lib/dynamic/constant-speed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const identity = require('../linalgebra/identity.js');
1+
const {identity} = require('simple-linalg');
22

33
/**
44
*Creates a dynamic model, following constant position model with respect with the dimensions provided in the observation parameters

lib/kalman-filter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const extendDynamicInit = require('../lib/setup/extend-dynamic-init.js');
77
const toFunction = require('../lib/utils/to-function.js');
88
const deepAssign = require('../lib/utils/deep-assign.js');
99
const polymorphMatrix = require('../lib/utils/polymorph-matrix.js');
10-
const distanceMat = require('../lib/linalgebra/distance-mat.js');
10+
const {frobenius: distanceMat} = require('simple-linalg');
1111
const State = require('./state.js');
1212
const modelCollection = require('./model-collection.js');
1313
const CoreKalmanFilter = require('./core-kalman-filter.js');

lib/linalgebra/add.js

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

0 commit comments

Comments
 (0)