a bugfix gps location algorithm..

This commit is contained in:
Dooho Yi 2024-10-12 19:16:25 +09:00
parent 6d65616f6b
commit bcb6e31c4b
3 changed files with 6 additions and 4 deletions

View file

@ -157,6 +157,8 @@
fill('white');
translate(30, 200, 0);
Textline.restart();
Textline.put('heading');
Textline.put(heading);
Textline.put('ang');
Textline.put(target.ang);
Textline.put('angerr');

View file

@ -26,7 +26,7 @@ class Sounder {
//
// this.ang = getBearing(latitude, longitude, this.latitude, this.longitude); (deg)
this.ang = getBearing(latitude, longitude, this.latitude, this.longitude); // (deg)
this.angerr = (((this.ang - heading + 360) % 360) + 180) % 360 - 180;
this.angerr = (heading - this.ang + 360) % 360;
this.dist = getDistance(latitude, longitude, this.latitude, this.longitude); // (km)
//
this.distvol = map(this.dist, this.distmap[0], this.distmap[1], this.distmap[2], this.distmap[3], true); //(dB)
@ -106,7 +106,7 @@ class Compass {
circle(0, 0, 0.9);
//
fill(this.colors[1]);
rotate(this.heading);
rotate(this.heading * -1);
quad(0.1, 0.2, 0, -0.4, -0.1, 0.2, 0, 0.1);
//
fill(this.colors[2]);

View file

@ -8,7 +8,7 @@ if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
if (response == 'granted') {
window.addEventListener("deviceorientation", (event) => {
if (event.webkitCompassHeading) {
heading = event.webkitCompassHeading;
heading = (event.webkitCompassHeading + 180) % 360 - 180; // EAST == +90, WEST == -90
}
}, true);
}
@ -17,7 +17,7 @@ if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
}
} else {
window.addEventListener("deviceorientationabsolute", (event) => {
heading = event.alpha * -1;
heading = ((360 - event.alpha) + 180) % 360 - 180; // EAST == +90, WEST == -90
}, true);
}