distance

find Distance in kilometers in Android using google places Api

牧云@^-^@ 提交于 2019-12-01 10:45:10
问题 I want display the two places distance in kilometers for that I write the following code: hyd(17.38,78.48) eluru(16.7,81.1) private String getDistance(double lat1, double lat2, double lon1, double lon2) { double Radius = 6371; double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lon2 - lon1); double a = Math.sin(dLat / 5) * Math.sin(dLat / 5) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 5) * Math.sin(dLon / 5); double c = 2 * Math

Heuristics to sort array of 2D/3D points according their mutual distance

元气小坏坏 提交于 2019-12-01 08:57:23
问题 Consider array of points in 2D,3D,(4D...) space ( e.g. nodes of unstructured mesh ). Initially the index of a point in array is not related to its position in space. In simple case, assume I already know some nearest neighbor connectivity graph. I would like some heuristics which increase probability that two points which are close to each other in space would have similar index (would be close in array). I understand that exact solution is very hard (perhaps similar to Travelling salesman

Mahalanobis distance on R for more than 2 groups

大兔子大兔子 提交于 2019-12-01 08:47:39
I need to calculate the mahalanobis distance for a numerical dataset of 500 independent observations grouped in 12 groups (species). I know how to compare two matrices , but I do not understand how to calculate mahalanobis distance from my dataset i.e. between the 12 species. R documentation gives mahalanobis(x, center, cov, inverted = FALSE, ...) x is the matrix, cov is covariance matrix ( cov(x) ) but I do not understand how I can calculate the metric for the 12 groups I found this question on mahalanobis but it does not answer really my question Getting the distances is straigtforward if

how to extract intragroup and intergroup distances from a distance matrix? in R

孤街浪徒 提交于 2019-12-01 08:36:04
问题 I have this dataset: values<-c(0.002,0.3,0.4,0.005,0.6,0.2,0.001,0.002,0.3,0.01) codes<-c("A_1","A_2","A_3","B_1","B_2","B_3","B_4","C_1","C_2","C_3") names(values)<-codes In the codes, the letter indicates a group and the number a case within each group. Therefore I have three groups and 3 to 4 cases in each group (the actual dataset is much larger but this is a subset). Then I calculate the distance matrix: dist(values)->dist.m Now I would like to convert the dist.m in a dataset with two

Error in .pointsToMatrix(x) : longitude > 360 with calculating distance

≯℡__Kan透↙ 提交于 2019-12-01 08:13:44
Im trying to calculate the nearest distance to a point. Therefore I create two df's Create list 1 long <- c(52.070498, 52.370216, 52.632381, 53.201233, 51.813298, 51.92442, 52.266075, 53.219383, 52.960561, 52.367027, 51.571915, 52.516775, 51.441642, 52.221537, 52.090737, 51.985103, 51.560596) lat <- c(4.3007, 4.895168,4.753375, 5.799913, 4.690093, 4.477733, 6.155217, 6.566502, 5.920522, 6.668492, 4.768323, 6.083022, 5.469722, 6.893662, 5.12142, 5.89873, 5.091914) stad <- c("Den Haag", "Amsterdam", "Alkmaar", "Leeuwarden", "Dordrecht", "Rotterdam", "Deventer", "Groningen", "Heerenveen", "Almelo

Finding out distance between router and receiver?

懵懂的女人 提交于 2019-12-01 06:39:37
A general question: is it possible to retrieve information about how far away e.g. a computer is from a wifi-router. For instance I want to get data on my computer if I'm 10 meters away from my home-wifispot or 2 meters. Any idea if that is even possible? Edit: How about bluetooth? Is it possible to get information about how far away bluetooth-connected devices are one from another? I would recommend a measuring line or just good-old-fashioned guesstimating. There is no "simple" way to do it (complex ways may involve building "accurate" signal maps ahead of time or trying to fit a better

How to Build a Distance Matrix without a Loop (Vectorization)?

前提是你 提交于 2019-12-01 06:39:10
I have many points and I want to build distance matrix i.e. distance of every point with all of other points but I want to don't use from loop because take too time... Is a better way for building this matrix? this is my loop: for a setl with size: 10000x3 this method take a lot of my time :( for i=1:size(setl,1) for j=1:size(setl,1) dist = sqrt((xl(i)-xl(j))^2+(yl(i)-yl(j))^2+... (zl(i)-zl(j))^2); distanceMatrix(i,j) = dist; end end How about using some linear algebra? The distance of two points can be computed from the inner product of their position vectors, D(x, y) = ∥y – x∥ = √ ( x T x +

Calculating distance using latitude longitude coordinates in kilometers with Java

荒凉一梦 提交于 2019-12-01 04:44:20
问题 I have following method that that calculates distance and returns it in miles: public static int calcDistance(float latA, float longA, float latB, float longB) { double theDistance = (Math.sin(Math.toRadians(latA)) * Math.sin(Math.toRadians(latB)) + Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians(longA - longB))); return new Double((Math.toDegrees(Math.acos(theDistance))) * 69.09).intValue(); } What needs to be changed in order for this method to

Python, Pairwise 'distance', need a fast way to do it

一世执手 提交于 2019-12-01 04:01:34
For a side project in my PhD, I engaged in the task of modelling some system in Python. Efficiency wise, my program hits a bottleneck in the following problem, which I'll expose in a Minimal Working Example. I deal with a large number of segments encoded by their 3D beginning and endpoints, so each segment is represented by 6 scalars. I need to calculate a pairwise minimal intersegment distance. The analytical expression of the minimal distance between two segments is found in this source . To the MWE: import numpy as np N_segments = 1000 List_of_segments = np.random.rand(N_segments, 6)

calculate distance between regression line and datapoint

这一生的挚爱 提交于 2019-12-01 02:22:15
I wonder if there is a way to calculate the distance between a abline in a plot and a datapoint? For example, what is the distance between concentration == 40 with signal == 643 (element 5) and the abline? concentration <- c(1,10,20,30,40,50) signal <- c(4, 22, 44, 244, 643, 1102) plot(concentration, signal) res <- lm(signal ~ concentration) abline(res) You are basically asking for the residuals . R> residuals(res) 1 2 3 4 5 6 192.61 12.57 -185.48 -205.52 -26.57 212.39 As an aside, when you fit a linear regression, the sum of the residuals is 0: R> sum(residuals(res)) [1] 8.882e-15 and if the