distance

Distance calculator between the ports

柔情痞子 提交于 2019-12-05 06:56:57
问题 I have a port database which contain nearly 10k port names and its corresponding locations.I want to find the distance between the ports. Form my understanding using Google distance matrix API, we can only able to find distance between the two points for a set of specific travel modes like bicycle,driving,walking and internal transit. But In my case I want to find the distance between two ports during the ship voyage. If anyone done Similar sort of work please share your knowledge...

Algorithm to find all points on a 2D grid some distance away from another point

最后都变了- 提交于 2019-12-05 06:14:13
I have some point on a 2D grid (x, y) and I need to find all points that are n distance away from that point. The way I'm measuring distance is by using the distance formula between the two points. Anyone know how to do this? Edit: Just for reference, what I'm trying to do is to write some AI path finding that will maintain some distance away from a target in a system that uses grid based locations. Currently I'm using A* path finding, but I'm not sure if that matters or makes a difference since I'm kind of new to this stuff. Here's what I would do: First filter out all points that are further

Distance between two lat,lon points

霸气de小男生 提交于 2019-12-05 06:08:14
Is it ok to compare distances in a classic way (distance between 2 points: d = sqrt(pow(lat2-lat1, 2) + pow(lon2-lon1, 2)) ) using the latitude and longitude returned from google apis without any transformation to meters or sth? I need it just for a comparison to find the closest point from a series of points to a reference point. For example: Lets say we have two (lat,lon) points: (40.2535425,22.88245345) and (40.2565795,22.8884539) and we want to find witch is closest to (40.2335425,22.83245345). Is it ok to apply the above code to find the distances? Or we need to find the distance, lets

Google maps distance approximation

拟墨画扇 提交于 2019-12-05 05:49:23
I've started to create a website where it's users are effectively tracked (they know they are being tracked). Users will walk a particular route (around Manchester, UK. to be more precise) of which there are 10 checkpoints. A checkpoint is a static position on the map. Using the Google Maps API I know that I can plot a position on a map i.e. a checkpoint. I am also storing the time at which a user reaches said checkpoint. Taking the distance between checkpoints I am then able to calculate their average speed using basic math. Now what I would like to do is plot their estimated position based

Find distance between 2 points in fastest way

时光怂恿深爱的人放手 提交于 2019-12-05 02:10:03
问题 This code calculates the distance between 2 points by using distance formula, Math.sqrt ( (x1 – x2)^2 + (y1 – y2) ^2) . My first point has mmx and mmy coordination and second one has ox and oy coordination. My question is simple, is there any FASTER way for calculate this? private function dist(mmx:int, mmy:int, ox:int, oy:int):Number{ return Math.sqrt((mmx-ox)*(mmx-ox)+(mmy-oy)*(mmy-oy)); } This is my code, Thanks for help. public function moveIT(Xmouse, Ymouse):void{ f = Point.distance( new

SQL Server 2008 Geography .STBuffer() distance measurement units

旧时模样 提交于 2019-12-05 02:03:17
I'm working with a geographic point using lat/long and need to find other points in our database within a 5 mile radius of that point. However, I can't seem to find out what the "units" are for STBuffer, it doesn't seem to conform to feet, miles, meters, kilometers, etc. The documentation only refers to them as "units", any suggestions? Thanks [...] from geography::STGeomFromText('POINT(x y)', 4326).STBuffer(z).STIntersects(geography::STGeomFromText('POINT(' + CAST(v.Longitude as varchar(max)) + ' ' + CAST(v.Latitude as varchar(max)) + ')', 4326)) = 1 STBuffer is in meters. More info here. To

Find Closest Vector from a List of Vectors | Python

家住魔仙堡 提交于 2019-12-05 01:40:03
If you are given say a list of 10 vectors, called A that represent different groups. Then you have a time series of vectors v1,v2,...,vn, each being a vector as well. I was wondering if there was a way to find the "closest" vector in A for each v1,v2,...,vn if you define some distance metric? Is there a quick way to do this besides for looping through and just comparing all entries? Edit: No I am not asking how to do k-means or something like that. haraldkl You can use the spatial KDtree in scipy . It uses a fast tree algorithm to identify close by points for vectors of arbitrary dimension.

Optimization from partial solution: minimize sum of distances between pairs

时光总嘲笑我的痴心妄想 提交于 2019-12-05 01:15:33
I have a problem which I like and I love to think about solutions, but I'm stuck unfortunately. I hope you like it too. The problem states: I have two lists of 2D points(say A and B) and need to pair up points from A with points from B, under the condition that the sum of the distances in all pairs is minimal. A pair contains one point from A and one from B, a point can be used only once, and as many as possible pairs should be created(i.e. min(length(A), length(B)) ). I've made a simple example, where color denotes which list the point is from, and the black connections are the solution.

Internationalization of distances in java

帅比萌擦擦* 提交于 2019-12-05 00:47:04
Is it possible in Java without any extra library to internationalize distances? I mean it is possible to handle that with date, time, currencies, numbers... I would have expected to find a NumberFormat.getDistanceInstance or something. Is there something like that already embedded or should i make my own internationalization system for distances (mostly miles vs kilometers) I would love to hear about such formatter but unfortunately I never did. The problem is, there is no such data in CLDR yet, so it is not to easy to do. That is to say that people actually think about this for quite a while

Cutting dendrogram into n trees with minimum cluster size in R

假如想象 提交于 2019-12-05 00:30:45
问题 I'm trying to use hirearchical clustering (specifically hclust ) to cluster a data set into 10 groups with sizes of 100 members or fewer, and with no group having more than 40% of the total population. The only method I currently know is to repeatedly use cut() and select continually lower levels of h until I'm happy with the dispersion of the cuts. However, this forces me to then go back and re-cluster the groups I pruned to aggregate them into 100 member groups, which can be very time