distance

Find K nearest neighbors, starting from a distance matrix

断了今生、忘了曾经 提交于 2019-11-26 08:30:25
问题 I\'m looking for a well-optimized function that accepts an n X n distance matrix and returns an n X k matrix with the indices of the k nearest neighbors of the ith datapoint in the ith row. I find a gazillion different R packages that let you do KNN, but they all seem to include the distance computations along with the sorting algorithm within the same function. In particular, for most routines the main argument is the original data matrix, not a distance matrix. In my case, I\'m using a

Calculate second point knowing the starting point and distance

♀尐吖头ヾ 提交于 2019-11-26 07:59:11
问题 using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values. Example (Pseudo code): PointA_Lat = x.xxxx; PointA_Lng = x.xxxx; Distance = 3; //Meters bearing = 0; //radians new_PointB = PointA-Distance; I was able to calculate the distance between two Points but what I want to find is the second point knowing the distance and bearing. Preferably in PHP or

Distance moved by Accelerometer

十年热恋 提交于 2019-11-26 07:28:54
问题 I want to move objects on iPhone screen (rectangle, circle and so on) by moving iPhone. For example, I move iPhone along X-axis and the object moves along X-axis. The same for Y,Z-axis. How can I do this? Can I get algorithm for it? Thank you. P.S: I looked for a while and seems like it is possible using accelerometer. 回答1: You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice. Here is an explanation why (Google Tech Talk) at 23:20.

Find cosine similarity between two arrays

允我心安 提交于 2019-11-26 07:24:36
问题 I\'m wondering if there is a built in function in R that can find the cosine similarity (or cosine distance) between two arrays? Currently, I implemented my own function, but I can\'t help but think that R should already come with one. 回答1: These sort of questions come up all the time (for me--and as evidenced by the r -tagged SO question list--others as well): is there a function, either in R core or in any R Package, that does x? and if so, where can i find it among the +2000 R Packages in

Is it possible to measure distance to object with camera?

删除回忆录丶 提交于 2019-11-26 07:23:13
问题 Is it possible to measure distance to object with phone camera? I mean, in my application I start the camera, facing the camera to the object (lets say house) and then press the button and it calculates the distance and shows me in screen. If it\'s possible where I can find some tutorial or information about it? 回答1: Well you should read how ithinkdiff.com "measures" the distance: Uses the angle of the iPhone to estimate the distance to a point on the ground. Hold the iPhone in front of you,

How to calculate distance from a point to a line segment, on a sphere?

痴心易碎 提交于 2019-11-26 06:35:57
问题 I have a line segment (great circle part) on earth. The line segment is defined by the coordinates of its ends. Obviously, two points define two line segments, so assume I am interested in the shorter one. I am given a third point, and I am looking for the (shortest) distance between the line and the point. All the coordinates are given in longitude\\latitude (WGS 84). How do I calculate the distance? A solution in any reasonable programming language will do. 回答1: Here's my own solution,

Geo-Search (Distance) in PHP/MySQL (Performance)

眉间皱痕 提交于 2019-11-26 06:00:44
问题 I have a MySQL-table (MyISAM) containing about 200k entries of lat/long pairs that I select from, based on the pairs distance (great circle formula) from another lat/long pair. (e.g. all entries that are within a 10km radius around 50.281852, 2.504883) My problem is that this query takes about 0,28 sec. to run just for those 200k entries (which continue to get more every day). While 0,28 sec. would be fine normally, this query runs very often as it powers the main feature of my web-app, and

Get lat/long given current point, distance and bearing

扶醉桌前 提交于 2019-11-26 05:17:24
问题 Given an existing point in lat/long, distance in (in KM) and bearing (in degrees converted to radians), I would like to calculate the new lat/long. This site crops up over and over again, but I just can\'t get the formula to work for me. The formulas as taken the above link are: lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ)) lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2)) The above formula is for MSExcel where- asin = arc sin() d = distance (in any

Edit Distance in Python

我的梦境 提交于 2019-11-26 04:46:57
问题 I\'m programming a spellcheck program in Python. I have a list of valid words (the dictionary) and I need to output a list of words from this dictionary that have an edit distance of 2 from a given invalid word. I know I need to start by generating a list with an edit distance of one from the invalid word(and then run that again on all the generated words). I have three methods, inserts(...), deletions(...) and changes(...) that should output a list of words with an edit distance of 1, where

R - Finding closest neighboring point and number of neighbors within a given radius, coordinates lat-long

最后都变了- 提交于 2019-11-26 04:45:24
问题 I am trying to figure out how isolated certain points are within my data set. I am using two methods to determine isolation, the distance of the closest neighbor and the number of neighboring sites within a given radius. All my coordinates are in latitude and longitude This is what my data looks like: pond lat long area canopy avg.depth neighbor n.lat n.long n.distance n.area n.canopy n.depth n.avg.depth radius1500 A10 41.95928 -72.14605 1500 66 60.61538462 AA006 41.96431 -72.121 250 0 57