android,ios,path,location,distance

What you are looking for is the Google Maps Android API utility library. The library has a class SphericalUtil which provides the static method public static double computeLength(List<LatLng> path); The library holds several other convenient methods for computing area, heading and other things as well. Simply add the library as...

SELECT ST_Length(ST_GeographyFromText(ST_AsText(ST_Line_Substring(line,ST_Line_Locate_Point(line,ST_ClosestPoint(line,fpt)),ST_Line_Locate_Point(line,ST_ClosestPoint(line,tpt)))))) As length_m, ST_Distance(ST_ClosestPoint(line,tpt)::geography, tpt::geography) as to_point_to_line_m, ST_Distance(ST_ClosestPoint(line,fpt)::geography, fpt::geography) as from_point_to_line_m, ST_AsText(ST_ClosestPoint(line,tpt)) as to_point_on_line, ST_AsText(ST_ClosestPoint(line,fpt)) as from_point_on_line, ST_AsText(tpt) as to_point,...

It's more math knowledge that you should knew. Distance between two objects is a length of vector between their coordinates. Farseer uses Xna type Vector2 or Vector3. Just subtract two needed vectors to get the needed one and get Length through the method on the corresponding vector type. Fixture's coordinates...

ios,objective-c,sprite-kit,distance

You can use the SKConstraint class to maintain the distance between the two nodes. For example : let node1 = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(20, 10)) node1.position = CGPointMake(self.size.width/2, self.size.height/2) self.addChild(node1) let node2 = SKSpriteNode(color: UIColor.blueColor(), size: CGSizeMake(10, 20)) node2.position = CGPointMake(self.size.width/2, self.size.height/2 - 50) self.addChild(node2) // The upper and lower...

java,loops,distance,rgb,raytracing

It looks like you're having difficulties with scope. If you declare variables inside a block, like you do in the case of if (something) { double x = ...; }, the variables are visible only inside the declared block. If you later want to access these variables, you have to...

java,distance,getter-setter,coordinate,euclidean-distance

As @Dude pointed out in the comments, you should write a method: public double distanceTo(Point3d p) { return Math.sqrt(Math.pow(x - p.getxCoord(), 2) + Math.pow(y - p.getyCoord(), 2) + Math.pow(z - p.getzCoord(), 2)); } Then if you want to get the distance between 2 points you just call: myPoint.distanceTo(myOtherPoint); //or if...

c#,algorithm,geometry,distance

The simplest heuristic with reasonable performance is 2-opt. Put the points in an array, with the start point first and the end point last, and repeatedly attempt to improve the solution as follows. Choose a starting index i and an ending index j and reverse the subarray from i to...

python,python-2.7,opencv,distance,cross-correlation

no wonder. apart from CV_COMP_BHATTACHARYYA not being a valid compare flag for matchTemplate , both CV_COMP_BHATTACHARYYA and TM_CCORR_NORMED resolve to the same enum value 3 under the hood. so basically you're doing the very same thing twice....

algorithm,3d,geometry,distance,computational-geometry

Find affine transform M that translates this ellipse in axis-oriented one (translation by -p and rotation to align orientation vector r and proper coordinate axis). Then apply this transform to point p and check that p' lies inside axis-oriented ellipsoid, i.e. x^2/a^2+ y^2/b^2+z^2/c^2 <= 1

python,performance,binary,distance

You can use numpy's vectorization capabilities to speed up the calculation. My version computes all elements of the distance matrix at once and then sets the diagonal and the lower triangle to zero. def pairwise_distance2(s): # we need this because we're gonna divide by zero old_settings = np.seterr(all="ignore") N =...

mongodb,matrix,distance,point,asymmetric

What measure of "distance" are you using, out of curiosity? Technically, you can't call a function d(X, Y) a "distance" unless d(X, Y) = d(Y, X) always. Distance between points on a sphere is symmetric so you can't be using that metric. If all you want to do is store...

library(maps) data(us.cities) d <- dist(head(us.cities[c("lat", "long")])) ## 1 2 3 4 5 ## 2 20.160489 ## 3 23.139853 40.874243 ## 4 15.584303 9.865374 38.579820 ## 5 27.880674 7.882037 48.707100 15.189882 ## 6 26.331187 41.720457 6.900101 41.036931 49.328558 library(reshape2) df <- melt(as.matrix(d), varnames = c("row", "col")) df[df$row > df$col,] ## row...

isNeighbor() works for undirected graphs or if you don't care how the two nodes are connected (that is, which way the existing edge, if any, goes) . For a directed Graph you probably want isPredecessor().

The GIS term you are describing is linear referencing, and Shapely has these methods. # Length along line that is closest to the point print(line.project(p)) # Now combine with interpolated point on line np = line.interpolate(line.project(p)) print(np) # POINT (5 7) ...

c#,charts,distance,mschart,series

This assumes that you want to do some sort of interpolation between points if the two series do not have the same number of points. A simple linear interpolation should work for a sufficiently large number of points, and so the whole algorithm could look something like this (in pseudo-code):...

I think this does what you want. The number of reference colors is arbitrary (3 in your example). Each reference color is defined as a row of the matrix ref_colors. Let MxN denote the number of pixels in the original image. Thus the original image is an MxNx3 array. result_index...

I am not an expert on your application so this is a general answer - hope it helps. Any function of coulourDistance and edgeDistance could work. You could think of what you described as testing three possible functions: f1(colourDistance, edgeDistance) = colourDistance f2(colourDistance, edgeDistance) = edgeDistance f3(colourDistance, edgeDistance) = (colourDistance...

You need to apply float left to both boxes and set your margin-right to appropriate value. delete style from this : <div class="content-small" style="float: left;"></div> <div class="content-small" style="float: right;"></div> so that they become : <div class="content-small"></div> <div class="content-small"></div> and then change your css like this: div.content-small { text-align: justify; color:...

javascript,arrays,order,distance,shuffle

That's not simple, I must admit. Let's start with some helper functions: Array.prototype.unique = function() { var i = 0, t = 1, l = (this.length >>> 0) - 1; for (; i < l; t = ++i + 1) while ((t = this.indexOf(this[i], t)) !== -1) this.splice(t, 1); return...

SQLite has no square root function, but for comparing distances, we can just as well use the square of the distance: SELECT * FROM MyTable ORDER BY min((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0), (x2-x0)*(x2-x0) + (y2-y0)*(y2-y0)) LIMIT 1 ...

java,dictionary,data-structures,distance,comparator

You can always distinguish instances that have the same distance to the reference number by doing further comparison when the distances are the same. For instance, assuming you represent your numbers as Integers: public int compare(Integer i1, Integer i2) { Integer r1 = hammingDistanceToReference(i1); Integer r2 = hammingDistanceToReference(i2); if (!r1.equals(r2))...

string,algorithm,big-o,edit,distance

Thank you @Roberto Attias for his answer, but the following is the complete algorithm I am looking for: L1 = length(string1) L2 = length(string2) for i in L1: table[i][0] = i for i in L2: table[0][i] = i for i in L1: for j in L2: m = minimum(table[i-1][j],table[i][j-1])+1 if...

python,arrays,distance,euclidean-distance

Another solution to #1: print(S.to_string()) # print the entire table and to get distances # assumes Python 3 from functools import partial def dist(row, col1, col2): return sum((c2 - c1)**2 for c1,c2 in zip(row[col1], row[col2])) ** 0.5 # compose a function (name the columns it applies to) s_dist = partial(dist,...

Do a select on your database, to get all the locations which are inside of a square that includes exactly your "distance-circle". SELECT * FROM TblLocations WHERE longitude < x AND longitude > y AND latitude < a AND latitude > b; Put the data in a array, and give...

google-maps,netbeans,maps,distance

It looks like the Distance Matrix API is exposed via the Maven artifact identified as "google-maps-services-java" or Gradle artifact identified as: "com.google.maps:google-maps-services". To use this, setup a simple Maven project and include thisdependency as described in the README.md : <dependency> <groupId>com.google.maps</groupId> <artifactId>google-maps-services</artifactId> <version>(insert latest version)</version> </dependency> To use it, as...

You can do a CROSS JOIN to obtain all possible combinations of towns and things, and then calculate the Haversine distance between each town and thing. I use SELECT DISTINCT to make sure a town is only listed once in the result set. SELECT DISTINCT TOWNS.townName FROM TOWNS CROSS JOIN...

Your 'non-traditional' vectors are usually called 'sparse vectors' (or in general, 'sparse matrices'). Scipy has a package to create them and perform algebraic operations on them. Here is more or less what you want: import numpy as np from scipy.sparse import csr_matrix def parse_sparse_vector(line): tokens = line.split() indexes = []...

Here : class Point{ int x; int y; ..... ..... public double distance(int x, int y) { double d = Math.sqrt( Math.pow(x2-x1, 2) + Math.pow(y2-y1, 2) ); //ERROR IN THIS LINE return distance; //ERROR HERE TOO...(2) } } There is no x1,x2,y1,y2 defined in the class or in the method...

unity3d,distance,visible,light

Maybe nobody answered before because it is very well documented on unity's manual. http://docs.unity3d.com/Manual/script-GlobalFog.html If adjusting this distance/height attributes from global fog doesn't fit your needs then you can find some third-party fog system on unity store, but what you described in your question is apparently possible with genuine fog...

ios,objective-c,geometry,distance

First of all, your calculation of the column and line index is not correct (it gives a wrong result for the last cell in each row). If the grid has 15 columns and the first cell has #1 then it should be: int columnTarget = (targetCoordinate - 1) % 15;...

algorithm,geolocation,distance

The maximum distance between any pair of points in a set of points is called the diameter of the set. Here is one efficient algorithm, based on the convex hull, for solving this problem: http://www.tcs.fudan.edu.cn/rudolf/Courses/Algorithms/Alg_ss_07w/Webprojects/Qinbo_diameter/2d_alg.htm http://cgm.cs.mcgill.ca/~athens/cs507/Projects/2000/MS/diameter/node2.html Since you probably don't care about exactness here, it would be easier to just...

Maybe this is of any help: public static int? GetDegreeOfRelationship(Type typeA, Type typeB) { if (typeA.IsInterface || typeB.IsInterface) return null; // interfaces are not part of the inheritance tree if (typeA == typeB) return 0; int distance = 0; Type child; if (typeA.IsAssignableFrom(typeB)) { child = typeB; while ((child =...

matlab,image-processing,computer-vision,distance

Use morphological operations. Let M be your matrix with zeros (no object) ones and twos indicating the locations of different objects. M1 = M == 1; % create a logical mask of the first object M2 = M == 2; % logical mask of second object dM1 = imdilate( M1,...

Find the difference quaternion qd = inverse(q1)*q2). Than find the angle between q1 and q2 by angle = 2 * atan2(qd.vec().length(), qd.w()) // NOTE: signed The "angle" here, is the angle of rotation from q1 to q2 by shortest arc....

As always, it depends on the data, in this case, what your shapes are like and any useful information about your starting point (will it often be close to a border, will it often be near the center of mass, etc). If they are similar to what you show, I'd...

dataset,artificial-intelligence,distance,hierarchy

Whether or not looking at distances of the means of your data-sets is good enough depends entirely on your data-sets. In general, the mean is sensitive to outliers. This means that if your data-sets have a few values that are wildly different than the others, they will have a notable...

javascript,variables,time,distance

That's an immense amount of code for a relatively simple problem. You should encode the distances as data tables instead of logic, and put the vehicle speeds directly into the form as the value attribute of the individual option elements: The code below does the whole thing: var distances =...

Try with max: max [distancexy 0 0] of patches with [pcolor = green] ...

distance,latitude-longitude,bearing

This is a prime example of why commenting your code makes it more readable and maintainable. Mathematically you are looking at the following: double ec = 6356725 + 21412 * (90.0 - LAT) / 90.0; //why? This is a measure of eccentricity to account for the equatorial bulge in some...

You can simply specify the distance calculation (say for example its (Longitude + Latitude) divided by 42) in the order by clause select ID, Name, Latitude, Longitude, (Longitude + Latitude) / 42 as Distance from YourTable order by (Longitude + Latitude) / 42 However, because the distance calculation is likely...

You want to find the unit vector in the direction you want; in XNA this is given by Vector3.Normalize. Then you can scalar multiply that unit vector (which has, by definition, length = 1) by the final distance. Ex.: var originalVector = new Vector3(1, 1, 2); var finalLength = originalVector.Length...

Finding the minimum distance to each triangle from the point and find the smallest minimum distance from them is the only way. This brute-force method will be very computationally expensive if you have many points to find the closest distance to the triangular mesh (which in turns could contain many...

android,google-maps,android-asynctask,maps,distance

The AsyncTask is being run before you get your location. You should move your async task to your onConnected of your location client so you know you can get a location from now on

android,json,google-maps,google-api,distance

I found my problem. I put my log statement to see my input stream result and found that my origin address (GPS coordinates) are 0,0. Hence there's no value for distance. try { InputStream is = null; httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); try { BufferedReader...

So, to find the distance between two points, say A and B located on a xy plane, where A and B are indices, here is what you need to do: double distanceSquared = Math.pow(coordsX[A] - coordsX(B), 2) + Math.pow(coordsY[A] - coordsY(B), 2); And if you just want to find the...

python,arrays,matrix,distance,pdist

This seems to work: for i in range(S.shape[0]): M = np.matrix( [S['x'][i], S['center'][i]] ) print pdist(M, 'euclidean') or with iterrows(): for row in S.iterrows(): M = np.matrix( [row[1]['x'], row[1]['center']] ) print pdist(M, 'euclidean') Note that the creation of a matrix isn't necessary, pdist will handle a python list of lists...

Entries with NA are first removed, then the distance is scaled up to account for the larger dimension of the full sample: i <- is.na(A) | is.na(B) dist(rbind(A[!i], B[!i])) * sqrt(length(A) / length(A[!i])) # A2 # B2 8.485281 ...

google-maps,distance,google-distancematrix-api

What I get from the distance matrix is (modifying this example): origin[0]:51.509904,-0.134135 origin[0]:A4, London W1J, UK to destination[0]:51.509904,-0.134135: 1 m in 1 min origin[0]:A4, London W1J, UK to destination[1]:51.517618,-0.096778: 4.1 km in 15 mins origin[0]:A4, London W1J, UK to destination[2]:51.501786,-0.053648: 7.4 km in 23 mins origin[0]:A4, London W1J, UK to...

This solution really focuses on readability over performance - It explicitly calculates and stores the whole n x n distance matrix and therefore cannot be considered efficient. But: It is very concise and readable. import numpy as np from scipy.spatial.distance import pdist, squareform #create n x d matrix (n=observations, d=dimensions)...

You can modify your last rule like this: connected(X,Y,Distance):- distance(X,Z,Distance1), distance(Z,Y,Distance2), SumDistance is Distance1+Distance2, write(SumDistance). Here is my result: 1 ?- connected(london,sydney,X). 12.2 true . The route is London -> Panama -> Sydney. I used trace. to see how it works: 2 ?- trace. true. [trace] 2 ?- connected(london,sydney,X) .......

matlab,image-processing,matrix,distance,vectorization

The basic workflow to solve this problem could be described as discussed below - Sort all the non-zero points. Start with the highest valued point and set all non-zeros points within its N-neighbourhood to zeros. Do the same for the second highest one and set all non-zeros points within its...

android,distance,gesture,repeat

Alright, the problem is that I was trying to move some view and I assigned touch listener (not intentionally) to view that was being moved. So that is what caused my "unexpected behavior".

Distance from the top would be row, int row = (int)(13/5); // 2 Distance from the left would be column, take the remainder of 13 by 5. int col = (int)(13%5); // 3 Distance from the right would be the column minus total columns (5) int colFromRight = 5-col-1; //...

algorithm,sorting,graph,distance

It can be done with dynamic programming. The graph is a DAG, so first do a topological sort on the graph, let the sorted order be v1,v2,v3,...,vn. Now, set D(v)=0 for all "end node", and from last to first (according to topological order) do: D(v) = max { D(u) +...

algorithm,graph,path,nodes,distance

One simple solution would be to first solve all-pairs shortest paths using n breadth-first searches from every node in O(n * (n + m)). Then create the graph of valid node pairs (x,y) with lambda(x, y) > D, with edges indicating the possible moves. There is an edge {(v,w), (x,y)}...

r,match,geospatial,distance,latitude-longitude

Is it this, want you were looking for? d <- outer(1:nrow(journey), 1:nrow(POI), FUN=function(i, j) earth.dist(journey[i,"lng"], journey[i,"lat"], POI[j,"lng"], POI[j, "lat"])) apply(apply(d, 1, "-", POI$rad) < 0, 2, function(x) POI$station[x]) ...

1) well I concluded that one cannot actually build an array that will fit the page no matter the character pitch (CPI) that the end user selects. This refers to pre-printed fanfold paper. Once the user decides to change CPI then they ought to reconfigure the positions of the text...

One option would be to convert the dist to matrix, replace the upper triangle values as 0, melt, subset the non-zero values, and then order based on the 'value' column. m1 <- as.matrix(dist_m) m1[upper.tri(m1)] <- 0 library(reshape2) m2 <- subset(melt(m1), value!=0) m2[order(m2$value),3:1] # value Var2 Var1 #4 2.645751 A D...

Here's one version let totalManhattanDistance board goal = let manhattanDistance ((x1, y1), (x2, y2)) = abs(x1 - x2) + abs(y1 - y2) let indexed xs = xs |> Seq.mapi (fun i -> Seq.mapi (fun j x -> (i, j), x)) |> Seq.concat |> Seq.sortBy snd |> Seq.map fst Seq.zip (indexed...

What you try to do is not possible if there is no structure in the list of points and they can really be random. Assume you have an algorithm that runs faster than in linear time, then in in your list of points there is one point B that is...

python,arrays,numpy,scipy,distance

First of all, thumbs up for a very clear and well written question. There is a very good and fast implementation of a Fast Marching method called scikit-fmm to solve this kind of problem. You can find the details here: http://pythonhosted.org//scikit-fmm/ Installing it might be the hardest part, but on...

You can retrieve the location from an address like this: public GeoPoint getLocationFromAddress(String strAddress) { Geocoder coder = new Geocoder(this); List<Address> address = new ArrayList<Address>(); try { address = coder.getFromLocationName(strAddress,5); if (address == null) { return null; } Address location = address.get(0); location.getLatitude(); location.getLongitude(); GeoPoint p1 = new GeoPoint((int) (location.getLatitude()...

vector,three.js,distance,points

Basically you need to get the direction vector between the two points (D), normalize it, and you'll use it for get the new point in the way: NewPoint = PointA + D*Length. You could use length normalized (0..1) or as an absolute value from 0 to length of the direction...

It is only one line of code to add these names as row and column names: df<-read.table(header=T,text='first second third 1 john 3 2 2 judy 6 4 3 jenny 9 6') df.dist=dist(df) df.dist=as.matrix(df.dist, labels=TRUE,) colnames(df.dist) <- rownames(df.dist) <- df[['first']] #this is the only line > df.dist john judy jenny john...

vector,redis,cassandra,nosql,distance

As far as I know, there are no databases with out-of-the-box support for non-(2|3)D spatial indexes yet, but you can implement your own inside your application layer. In general, you would like to have an efficient algorithm for N-dimensional nearest neighbour search like these: KD-Tree with overall O(log N) complexity...

This is what you could to to decrease your headache with so many variables: Create a structure to group all 3 coordinates of a point create and array for your points Like this: struct Point3 { double x, y, z; }; // <-- the semocolon (;) is mandatory here //...

python,scipy,scikit-learn,distance,sparse

CSR is ordered by rows, CSC is ordered by columns. So accessing rows would be faster with CSR and accessing columns would be faster using CSC. Since sklearn.metrics.pairwise.pairwise_distances uses as input, X, where the rows are instances and columns are attributes, it will be accessing rows from the sparse matrix....

If you want to find the nearest geo coord you should use specific geo-coordinate structures (please see geopy ). In this case, I propose the following solution: import geopy import geopy.distance # your data ccoordinate_list = [(11.6702634, 72.313323), (11.6723698, 78.114523), (31.67342698, 78.465323), (12.6702634, 72.313323), (12.67342698, 75.465323)] coordinate = (11.6723698, 78.114523)...

java,math,language-agnostic,distance

This is pretty simple: You move diagonally towards the goal until you're either on the same row or same col. This will be min(dx, dy) steps. Let's call this d (for diagonal steps) Then you move on a straight line towards the goal. This will be max(dx, dy) - d...

google-maps,distance,bing-maps

Another option is to use the Bing Maps Routing service. It's a bit more work but depending on your use case the free terms of use for Bing Maps are much higher. The routing service in Bing Maps allows up to 25 waypoints to be passed in a single response....

The number in the cell in column named "1" and row named "2" is the distance between the first and second rows of your data. So 2.236068 is the distance between the vectors c(1,6,11,16,21) and c(2,7,12,17,22) (rows 1 and 2), 4.472136 is the distance between vectors c(1,6,11,16,21) and c(3,8,13,18,23) (rows...

ios,core-location,distance,cllocationmanager

Based on the info provided, startMonitoringSignificantLocationChanges is the correct choice. The reason, and answer to your question, is that startMonitoringSignificantLocationChanges is a service that your app registers for and will continue to run even when your app is suspended or terminated. However, startUpdatingLocations is registered at the app level and...

android,geolocation,distance,geopoints,bearing

In your code: Location here = new Location("Current"); here.setLatitude(currentLat); here.setLatitude(currentLng); you set latitude twice. Corrected, it gives absolutely right result....

distance,shape,similarity,euclidean-distance

What distance function to use depends on your concrete task. I guess cosine similarity may be what you want....

matlab,grid,coordinates,distance

Please check the following code. Since as per your information both A and DC positions are not fixed, I assumed A as fixed for the moment. Let me know if it does not suite your requirement. clear all; s1 = [100 20]; s2 = [20 150]; s3 = [50 450];...

As you've found out, the base aggregate() function only works on one column at a time. Instead you could use the by() function by(data[,c("x","y")], data$group, pathlength) data$group: A [1] 9.964725 ----------------------------------------------------------------------- data$group: B [1] 2.828427 or split()/lapply() lapply(split(data[,c("x","y")], data$group), pathlength) $A [1] 9.964725 $B [1] 2.828427 ...

python,numpy,statistics,distance

After asking this same question in cross correlated @wuber edited my post by adding the multidimensional-scaling keyword. With this keyword I could find many algorithms, starting from the wikipedia: https://en.wikipedia.org/wiki/Multidimensional_scaling

Just record the displacement every x seconds or so, and sum the displacements. You will have a fairly good approximation. Or just record the points at different times first, and then do the calculation at the end. var checkpoints = [], interval = null; function record() { checkpoints.push( /* current...

python,pandas,distance,similarity,categorical-data

If you're concerned or reliant on categorical then another approach is to define your categories in a list and an order, use this to create a dict to map the order to the categories and pass this dict to map: In [560]: df = pd.DataFrame({'id' : range(1,9), 'rate' : ['bad',...

Here's an Rcpp version that returns an integer matrix of 1s and 0s dependent on whether each pair wide comparison is <= a threshold. On my machine it took 22.5 secs to do 30,000 by 30,000. The output matrix is a little under 7 GB in RAM though. fast_cal.cpp #include...

tree,binary,height,racket,distance

We only need one function - maxdepth, and we only have to find the max of each subtree plus the height of the current node: (define (maxdepth tree) (cond [(null? tree) 0] [else (+ 1 (max (maxdepth (node-left tree)) (maxdepth (node-right tree))))])) ...

mongodb,gps,distance,geospatial,geojson

The distances are being returned in meters. To convert to kilometers, divide by 1000. You can have MongoDB do this using the distanceMultiplier option: db.runCommand({ "geoNear" : "test", "spherical" : true, "distanceMultiplier" : 0.001, "near" : { "type" : "Point" , "coordinates" : [33.2926487, 44.4159651] } }) ...

mysql,distance,spatial-query,spatial-index

It doesn't help that Spot is indexed, MySQL still have to calculate each st_distance from the point 10.0, 12.0 to be able to order it. If you wan't to do searches like this fast you should add a where condition to narrow the number of points that can might close...

position,equals,distance,graphviz

This may be a case for invisible nodes (and edges...). Just add some invisible nodes between the rank=same subgraph to force exactly one node between the lines: graph Example { rankdir=LR ordering=out { rank=same b1 [group=b] c1 [group=c] d1 [group=d] e1 [group=e] // invisible nodes node[style=invis] edge[style=invis] b1--i1--c1--i2--d1--i3--e1 } node...

python,coordinates,distance,trigonometry,angle

You just need a function that converts degrees to radians. Then your function simply becomes: from math import sin, cos, radians, pi def point_pos(x0, y0, d, theta): theta_rad = pi/2 - radians(theta) return x0 + d*cos(theta_rad), y0 + d*sin(theta_rad) (as you can see you mixed up sine and cosine in...

Use the distance formula to find the length of each segment. Add those segment lengths to find total distance. The distance formula takes the square root of the sum of the squares of changes in x and y: Distance = sqrt(dx*dx + dy*dy) Where dx is x2-x1 and dy is...

python,arrays,numpy,scipy,distance

Distances between labeled regions of an image can be calculated with the following code, import itertools from scipy.spatial.distance import cdist # making sure that IDs are integer example_array = np.asarray(example_array, dtype=np.int) # we assume that IDs start from 1, so we have n-1 unique IDs between 1 and n n...

It's actually pretty easy, and the translation is pretty straight forward. You can continue to use your bit shifting. The only change is the syntax of for-loop and using ord() to get the integer value from a character. def decode(data, size, offset=0): value = 0 for ch in data[offset:size]: value...

The radius parameter is "only valid for requests with intent=browse, or requests with intent=checkin and categoryId or query. Does not apply to match intent requests." See documentation here. Are you using a different 'intent'?

android,gps,geolocation,distance,phone-number

To answer your question YES! Possible provided All the users within the prescribed radius should have GPS enabled and you should be having the lat/long of all users current coordinates(Or atleast last known coordinates should be saved periodically) saved in DB. To calculate the 5 km radius, you can use...

I might be late, but it looks like the first query do exectly what you want. Just remove some strange conditions and get all the users that are close to the specified point: SELECT publicSSID, nome, cognome, eta, sesso, foto, position.latitude, position.longitude, informazioni, (3956 * 2 * ASIN(SQRT( POWER(SIN(($lat -...

As explained in the scipy documentation, use scipy.spatial.distance.squareform to convert the condensed distance matrix returned by pdist to a square distance matrix, from scipy.spatial.distance import squareform dist_matrix = squareform(dist_array) ...

Getting the distances is straigtforward if you organize your data in a 500 by 12 data.frame or matrix. To show you, first we create a data.frame with some toy data: set.seed(1) # To ensure reproducibility of the random numbers df <- data.frame(sapply(LETTERS[1:12], function(x) rnorm(500))) # Adding some outliers df[1,1] <-...

6371.0 looks like the Earth's radius in km. Multiplying by Math.PI / 180 converts degrees to radians. This is turning a distance in radians to kilometers....