distance

Fastest available algorithm for distance transform

若如初见. 提交于 2019-11-27 18:33:28
I am looking for the fastest available algorithm for distance transform. According to this site http://homepages.inf.ed.ac.uk/rbf/HIPR2/distance.htm , it describes: "The distance transform can be calculated much more efficiently using clever algorithms in only two passes (e.g. Rosenfeld and Pfaltz 1968)." Searching around, I found: "Rosenfeld, A and Pfaltz, J L. 1968. Distance Functions on Digital Pictures. Pattern Recognition, 1, 33-61." But I believe we should have a better and faster algorithm than the one in 1968 already? In fact, I could not find the source from 1968, so any help is

How to find my distance to a known location in JavaScript

牧云@^-^@ 提交于 2019-11-27 17:54:00
Using JavaScript in the browser, how can I determine the distance from my current location to another location for which I have the latitude and longitude? Frank van Puffelen If your code runs in a browser, you can use the HTML5 geolocation API: window.navigator.geolocation.getCurrentPosition(function(pos) { console.log(pos); var lat = pos.coords.latitude; var lon = pos.coords.longitude; }) Once you know the current position and the position of your "target", you can calculate the distance between them in the way documented in this question: Calculate distance between two latitude-longitude

how to calculate distance while walking in android?

戏子无情 提交于 2019-11-27 17:53:29
I am developing a demo for my app, in which there are two buttons named as "START" and "STOP". When user taps on "START" he will start walking. What I want to do is make it so that when users tap "STOP" then the demo will calculate his distance between "START" and "STOP". If the user pressed "START" and pressed "STOP" without taking a single step, then it must show 0km or 0m. I don't have any idea how I should start this; please make a suggestion. One way to go about it is using the accelerometer data. Your app should continuously record the accelerometer data after the user presses the Start

Clustering with a distance matrix

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 17:52:23
问题 I have a (symmetric) matrix M that represents the distance between each pair of nodes. For example, A B C D E F G H I J K L A 0 20 20 20 40 60 60 60 100 120 120 120 B 20 0 20 20 60 80 80 80 120 140 140 140 C 20 20 0 20 60 80 80 80 120 140 140 140 D 20 20 20 0 60 80 80 80 120 140 140 140 E 40 60 60 60 0 20 20 20 60 80 80 80 F 60 80 80 80 20 0 20 20 40 60 60 60 G 60 80 80 80 20 20 0 20 60 80 80 80 H 60 80 80 80 20 20 20 0 60 80 80 80 I 100 120 120 120 60 40 60 60 0 20 20 20 J 120 140 140 140 80

Function to calculate geospatial distance between two points (lat,long) using R [duplicate]

可紊 提交于 2019-11-27 17:49:19
This question already has an answer here: Geographic / geospatial distance between 2 lists of lat/lon points (coordinates) 2 answers Calculate distance between two latitude-longitude points? (Haversine formula) 36 answers I have geocoded points in long, lat format, and I want to calculate the distance between them using R. This seems pretty straight forward, yet I can't find a function that will do it easily. I've been attempting to do it with the gdistance package, but it seems very convoluted and oriented to graphing, I just need a number. Something like distanceBetween(pointA,pointB) that

Effectively selecting the closest (distance) record from a database

人盡茶涼 提交于 2019-11-27 16:34:27
问题 I've got a database with a 40k venues and growing right now. Assuming I'm the red dot I want to be able to retrieve the closest record as quickly as possible. However the distance too the next item could be anything. And there also might be 0-n matches. But do I need to load all 40000 results when I'm just looking for 1? How can I sort the records by distance? Should it be done in MYSQL, or PHP? This calculation happens at almost every request, per user, per page, so the solution needs to be

Calculating all distances between one point and a group of points efficiently in R

拟墨画扇 提交于 2019-11-27 16:28:28
问题 First of all, I am new to R (I started yesterday). I have two groups of points, data and centers , the first one of size n and the second of size K (for instance, n = 3823 and K = 10 ), and for each i in the first set, I need to find j in the second with the minimum distance. My idea is simple: for each i , let dist[j] be the distance between i and j , I only need to use which.min(dist) to find what I am looking for. Each point is an array of 64 doubles, so > dim(data) [1] 3823 64 > dim

How to calculate distance between two rectangles? (Context: a game in Lua.)

本秂侑毒 提交于 2019-11-27 15:48:17
问题 Given two rectangles with x, y, width, height in pixels and a rotation value in degrees -- how do I calculate the closest distance of their outlines toward each other? Background: In a game written in Lua I'm randomly generating maps, but want to ensure certain rectangles aren't too close to each other -- this is needed because maps become unsolvable if the rectangles get into certain close-distance position, as a ball needs to pass between them. Speed isn't a huge issue as I don't have many

d3 force directed layout - link distance priority

老子叫甜甜 提交于 2019-11-27 15:36:43
Using a force-directed layout in d3, how do I make the link distance a priority, while still keeping a nice graph layout? If I specify dynamic link distances, but keep the default charge, my graph distances are morphed a bit by the charge function, and are no longer accurate distances: However, if I remove the charge, the graph looks like this: Any advice appreciated! If I understand correctly, I believe there is a potential solution. To get link distance to be accurate, you need to set charge and collision forces to zero, but as your image suggests, then nodes aren't spaced in a way that

Calculating distance of all the points in a region with each other

杀马特。学长 韩版系。学妹 提交于 2019-11-27 15:14:07
I have a region with about 144 points. What i want to achieve is to measure the distance of a point with all others and store it in an array. I want to do this for all the points. If possible i would like to store this data in such a manner that there in no repetition. And i should be able to make queries like- All the distances between all the points without repetition, sum of all the distances for point no56 etc. I have a 3*144 array with two columns storing the coordinates of the points. A possible solution (I am not really clear with what you mean by no repetition, though): X are your