distance

PHP/MySQL: Select locations close to a given location from DB

Hello! In PHP, I have the following code for calculating the distance between two locations: <?php function distance($lat1, $long1, $lat2, $long2) { // DEGREE TO RADIAN $latitude1 = $lat1/180*pi(); $longitude1 = $long1/180*pi(); $latitude2 = $lat2/180*pi(); $longitude2 = $long2/180*pi(); // FORMULA: e = ARCCOS (...

String distance library

Hi, I need to measure the distance between two strings (names of places). Since some times the names are written slightl differently I was looking for a library that could help me measure the difference and then combine it with a measure of the latitude and longitude to select the correct matches. Preferred languages: Java or Php Any s...

Equidistant points in a line segment

Let assume you have two points (a , b) in a two dimensional plane. Given the two points, what is the best way to find the maximum points on the line segment that are equidistant from each point closest to it with a minimal distant apart. Any help will be greatly appreciated. Thanks. I use c#, but examples in any language would be hel...

Distance from Point To Line great circle functino not working right. Need help

Howdy. I need to get the distance from a lat/lng point to a line. Of course needs to follow the Great Circle. I found a great article on this at http://www.movable-type.co.uk/scripts/latlong.html but the code is not working right. Either I am doing something wrong or there is something missing. Here is the function in question. See t...

Possible? Use Google Maps/GPS to tell how long someone has been in a location?

I'm thinking about building an iphone app that would use the GPS feature to track where someone is and for how long. I realize I could probably get the current location from the iphone from a website but the only way I'm familiar with is using ajax calls, etc (Sorry if this is a rather newbie concept) but I fear that would bog down my s...

UIScrollView Scroll Distance?

I am trying the scroll images (160x130) horizontally on the screen (portrait). So my pics are half the iphone screen width. I've looked at the scroll example from apple and kind of got it working. I got it to focus on one picture in the middle of the screen and half an image on the left and right. The thing is that because the UIScro...

I want to create a distance formula for 6 degree of freedom??

I have a sensor with 6 degree of freedom 3 axiz x,y,z and 3 angles yaw, pitch and roll. 3 axis distance is simple using distance formula but how to calculate 3 angular distances? Can anyone here please help me ??? ...

Storing distances in MySQL

I have a "colors" table in my database. The user enters a color trough the user interface, and the backend searches for the most similar looking color existing in the colors table, calculating the distance of the colors in the HCL space. I will implement a caching algorithm, which should store the distance between previously calculated...

2D Game: Fast(est) way to find x closest entities for another entity - huge amount of entities, highly dynamic.

I'm working on a 2D game that has a huge amount of dynamic entities. For fun's sake, let's call them soldiers, and let's say there are 50000 of them (which I just randomly thought up, it might be much more or much less :)). All these soldiers are moving every frame according to rules - think boids / flocking / steering behaviour. For ea...

Longest Distance Between Lat/Longs in a List

I have a database of geocoded entries. I need to determine which two entries are the furthest apart from a subset of the total entries. For example, I select a list of 10 entries then, from that list, determine which two places represent the greatest distance within that list. I cannot wrap my head around how to approach this. I've cons...

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

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 gi...

Naming this algorithm: Comparing and interpolating points?

Hello, my question might be a little strange. I've "developed" an algorithm and don't know if there's a similar algorithm already out there. The situation: I've got a track defined by track points (2D). The track points represent turns for instance. Between the track points there are only straight lines. Now I'm given a set of coordina...

which data structure is appropriate to query "all points within distance d from point p"

hey there! i have a 3D pointcloud and i'd like to efficiently query all points within distance d from an arbitrary point p (which is not necessarily part of the stored pointcloud) the querry would look something like Pointcloud getAllPoints(Point p, float d); what accelerationstructure would be appropriate for this? A range-tree see...

K-means clustering: What's wrong? (PHP)

Hello! I was looking for a way to calculate dynamic market values in a soccer manager game. I asked this question here and got a very good answer from Alceu Costa. I tried to code this algorithm (90 elements, 5 clustes) but it doesn't work correctly: In the first iteration, a high percentage of the elements changes its cluster. From ...

Maps: Does calculating distance between 2 points factor in altitude?

Does Postgres' Spatial plugin, or any Spatial package for that manner, factor in the altitude when calculating the distance between 2 points? I know the Spatial packages factor in the approximate curvature of the earth but if one location is at the top of a mountain and the other location is close to the sea - it seems like the calculat...

Google Maps API - "road" distance between 2 points

Hey guys, I have a website where "near locations" are shown for each item, based on the latitude and longitude coordinates stored in a database. Problem is that this calculated distance is the air-line distance, which differs a lot ferom the actual driving distance. Google Maps does only have a JavaScript API for driving directions ...

RegEx for distance in metric system

I want a RegEx to match distance values in metric system. This regex should match 12m, 100cm,1km ignoring white space ...

determining the distance between points in n-dimensions

Hey, I am building a mySQL table listing points in n-dimensions, each dimension being indexed. Given any point in the n-dimensional system, I would like to be able to output all of the other points in order of their distance from the chosen point. A simple solution would be to calculate distances from each point using the pythagorean ...

How do I find the lat/long that is x km east/west of a given lat/long?

Hi I have two given lat and lon points. For example, lets assume I have two positions (point_1 and point_2) at coordinates (lat1, lon1) and (lat2, lon2). I would like to calculate a third point, that is on the same latitude as that of point_2, but x km to the east or west of point_2. So the third point will have the same latitude a...

Distance between two locations using Latitude and Longitude way off what Google says.

I've spent a few days trying to figure this one out and can't seem to pinpoint the problems. I have a SQL 2005 database storing latitude and longitude as Decimal(18,8), all of which I received by querying Google. For these two locations: From: 10715 Downsville Pike Ste 100 MD 21740 to: 444 East College Ave Ste 120 State College PA, 168...