mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 11:29:53 +03:00
Merge branch 'master' of https://github.com/iNavFlight/inav-configurator into Electron
This commit is contained in:
commit
ca13eefa1b
32 changed files with 2988 additions and 796 deletions
|
@ -55,4 +55,50 @@ function scaleRangeInt(x, srcMin, srcMax, destMin, destMax) {
|
|||
return Math.round((a / b) + destMin);
|
||||
}
|
||||
|
||||
module.exports = { constrain, zeroPad, generateFilename, scaleRangeInt };
|
||||
function distanceOnLine(start, end, distance)
|
||||
{
|
||||
var vx = end[0] - start[0];
|
||||
var vy = end[1] - start[1];
|
||||
var mag = Math.sqrt(vx * vx + vy * vy);
|
||||
vx /= mag;
|
||||
vy /= mag;
|
||||
|
||||
var px = start[0] + vx * (mag + distance);
|
||||
var py = start[1] + vy * (mag + distance);
|
||||
|
||||
return [px, py];
|
||||
}
|
||||
|
||||
function wrap_360(angle)
|
||||
{
|
||||
if (angle >= 360)
|
||||
angle -= 360;
|
||||
if (angle < 0)
|
||||
angle += 360;
|
||||
return angle;
|
||||
}
|
||||
|
||||
function rad2Deg(rad)
|
||||
{
|
||||
return rad * (180 / Math.PI);
|
||||
}
|
||||
|
||||
function deg2Rad(deg)
|
||||
{
|
||||
return deg * (Math.PI / 180);
|
||||
}
|
||||
|
||||
function calculate_new_cooridatnes(coord, bearing, distance)
|
||||
{
|
||||
var lat = deg2Rad(coord.lat);
|
||||
var lon = deg2Rad(coord.lon);
|
||||
bearing = deg2Rad(bearing);
|
||||
var delta = distance / 637100000; // Earth radius in cm
|
||||
|
||||
var latNew = Math.asin(Math.sin(lat) * Math.cos(delta) + Math.cos(lat) * Math.sin(delta) * Math.cos(bearing));
|
||||
var lonNew = lon + Math.atan2(Math.sin(bearing) * Math.sin(delta) * Math.cos(lat), Math.cos(delta) - Math.sin(lat) * Math.sin(lat));
|
||||
return {
|
||||
lat: rad2Deg(latNew),
|
||||
lon: rad2Deg(lonNew),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue