Giter Site home page Giter Site logo

euctrl-pru / nvctr Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 0.0 1.82 MB

R :package: about n-vector for geographical position calculations using an ellipsoidal model of Earth :globe_with_meridians:

Home Page: https://nvctr.ansperformance.eu/

License: Other

R 100.00%
geographical-positions r rstats r-package n-vector

nvctr's Introduction

nvctr

R build status CRAN version

Overview

The nvctr package implements the n-vector approach to geographical position calculations using an ellipsoidal model of Earth as described in (Gade 2010).

Implementations in various computer languages can be found at the n-vector page (Navigation Group 2010).

Installation

You can install the development version of nvctr from GitHub with:

devtools::install_github("euctrl-pru/nvctr")

or the CRAN version (when this package will land to CRAN):

install.packages("nvctr")

Usage

nvctr can be used to solve geographical position calculation like (example numbers refer to the ones in the vignette):

  • Calculate the surface distance between two geographical positions (Example 5).
  • Find the destination point given start point, azimuth/bearing and distance (Example 8).
  • Find the mean position (center/midpoint) of several geographical positions (Example 6).
  • Find the intersection between two paths (Example 9).
  • Find the cross track distance between a path and a position (Example 10).

References

Gade, Kenneth. 2010. “A Non-Singular Horizontal Position Representation.” Journal of Navigation. https://doi.org/10.1017/S0373463309990415.

Navigation Group, FFI. 2010. “The N-Vector Page.” https://www.navlab.net/nvector/.

nvctr's People

Contributors

espinielli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nvctr's Issues

improve on EUROCONTROL logo

The current image for EUROCONTROL logo (from wikipedia) is the canonical one but it
could be beneficial to have one where the label is on the right of the logo:

EUROCONTROL

To be checked with Comms with regard to "Logo guidelines"

AppVeyor using tic

See past commit where tic version of AppVeyor was used: pandoc seemd to be the problem.
It would be nice to use tic for all.

add practical examples

From a request via email from Michael Henry from Australia about great circle intersection of
[point, bearing]_1 with [point, bearing]_2:

library(nvctr)
#> Warning: package 'nvctr' was built under R version 4.0.3

# find point on great circle at distance, from Example 8
point_at_distance <- function(n_EA_E, distance, azimuth, r_Earth = 6371e3) {
  k_east_E <- unit(pracma::cross(base::t(R_Ee()) %*%
                                   c(1, 0, 0) %>%
                                   as.vector(), n_EA_E))
  k_north_E <- pracma::cross(n_EA_E, k_east_E)
  d_E <- k_north_E * cos(azimuth) + k_east_E * sin(azimuth)
  n_EB_E <- n_EA_E * cos(distance / r_Earth) + d_E * sin(distance / r_Earth)
  n_E2lat_lon(n_EB_E)
}

# test 1
A <- c(-10, 0)
n_EA_E <- lat_lon2n_E(rad(A[1]), rad(A[2]))
azimuth <- rad(0)
s_AB <- 100000 # distance (m)
n_EB_E <- point_at_distance(n_EA_E, s_AB, azimuth)
(B <-  n_EB_E %>% deg()) # reassuringly longitude remains 0
#> [1] -9.100678  0.000000

# test 2
A <- c(0, -10)
n_EA_E <- lat_lon2n_E(rad(A[1]), rad(A[2]))
azimuth <- rad(90)
s_AB <- 100000 # distance (m)
n_EB_E <- point_at_distance(n_EA_E, s_AB, azimuth)
(B <-  n_EB_E %>% deg()) # reassuringly latitude remains 0 (well, close enough, 5.5e-17 !)
#> [1]  5.506349e-17 -9.100678e+00


# great circle intersection, from Example 9
great_circle_intersection <- function(n_EA1_E, n_EA2_E, n_EB1_E, n_EB2_E) {
  n_EC_E_tmp <- unit(pracma::cross(
    pracma::cross(n_EA1_E, n_EA2_E),
    pracma::cross(n_EB1_E, n_EB2_E)))
  n_EC_E <- sign(pracma::dot(n_EC_E_tmp, n_EA1_E)) * n_EC_E_tmp
  
  n_EC_E
}

# (too?) simple test
A1 <- c(-10, 0)
n_EA1_E <- lat_lon2n_E(rad(A1[1]), rad(A1[2]))
A2 <- c(10, 0)
n_EA2_E <- lat_lon2n_E(rad(A2[1]), rad(A2[2]))
B1 <- c(0, -10)
n_EB1_E <- lat_lon2n_E(rad(B1[1]), rad(B1[2]))
B2 <- c(0, 10)
n_EB2_E <- lat_lon2n_E(rad(B2[1]), rad(B2[2]))

n_EC_E <- great_circle_intersection(n_EA1_E, n_EA2_E, n_EB1_E, n_EB2_E)
(C <- n_E2lat_lon(n_EC_E) %>% deg()) # reassuringly gives (0, 0)
#> [1] 0 0

# ([less] too?) simple test
A1 <- c(-10, -10)
n_EA1_E <- lat_lon2n_E(rad(A1[1]), rad(A1[2]))
A2 <- c(10, 10)
n_EA2_E <- lat_lon2n_E(rad(A2[1]), rad(A2[2]))
B1 <- c(10, -10)
n_EB1_E <- lat_lon2n_E(rad(B1[1]), rad(B1[2]))
B2 <- c(-10, 10)
n_EB2_E <- lat_lon2n_E(rad(B2[1]), rad(B2[2]))

n_EC_E <- great_circle_intersection(n_EA1_E, n_EA2_E, n_EB1_E, n_EB2_E)
(C <- n_E2lat_lon(n_EC_E) %>% deg()) # reassuringly gives (0, 0)
#> [1] 0 0

Created on 2020-11-20 by the reprex package (v0.3.0)

Created on 2020-11-20 by the reprex package (v0.3.0)

Created on 2020-11-20 by the reprex package (v0.3.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.