distance

Nearest Neighbours using Quaternions

血红的双手。 提交于 2019-12-03 09:55:31
问题 Given a quaternion value, I would like to find its nearest neighbour in a set of quaternions. To do this, I clearly need a way to compare the "distance" between two quaternions. What distance representation is needed for such a comparison and how is it computed? Thanks, Josh 回答1: Is your quaternion just a point in 3D space with an orientation? Then the distance between two quaternions x1,y1,z1,w1 and x2,y2,x2,w2 is given by: distance = sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2) , assuming that

Programmatical approach in Java for file comparison

江枫思渺然 提交于 2019-12-03 09:32:39
问题 What would be the best approach to compare two hexadecimal file signatures against each other for similarities. More specifically, what I would like to do is to take the hexadecimal representation of an .exe file and compare it against a series of virus signature. For this approach I plan to break the file (exe) hex representation into individual groups of N chars (ie. 10 hex chars) and do the same with the virus signature. I am aiming to perform some sort of heuristics and therefore

Distance between 2 hexagons on hexagon grid

为君一笑 提交于 2019-12-03 09:32:15
问题 I have a hexagon grid: with template type coordinates T. How I can calculate distance between two hexagons? For example: dist((3,3), (5,5)) = 3 dist((1,2), (1,4)) = 2 回答1: First apply the transform (y, x) |-> (u, v) = (x, y + floor(x / 2)). Now the facial adjacency looks like 0 1 2 3 0*-*-*-* |\|\|\| 1*-*-*-* |\|\|\| 2*-*-*-* Let the points be (u1, v1) and (u2, v2). Let du = u2 - u1 and dv = v2 - v1. The distance is if du and dv have the same sign: max(|du|, |dv|), by using the diagonals if

“Distance” (or angular magnitude) between two quaternions?

社会主义新天地 提交于 2019-12-03 09:31:36
I want to find the "distance" between two quaternions. By "distance" I mean a single float or int, not another quaternion (that would be the difference, i.e. inverse(q1)*q2 ). I guess you could call what I want "angular magnitude". I need to apply more torque to a physics object the further it's rotated from its original angle. I don't understand the maths involved in quaternions, so a code-based example would be most helpful. I've looked at several other questions but I don't believe any answer my question, or at least not in a way I understand it. Find the difference quaternion qd = inverse

how to get Distance between wifi access point and Mobile Device

余生长醉 提交于 2019-12-03 09:11:37
i am developing an android application which have module to search all nearest / detected wifi hotspot. i can get all detail from searched wifi hotspot like, SSID, BSSID, capabilities, frequency, level and timestamp with these information, i also need Distance of wifi ( The distance between wifi accesspoint and Mobile Device ) i am using below lines to get Distance. double exp = (27.55 - (20 * Math.log10(freqInMHz)) + Math.abs(levelInDb)) / 20.0; double distanceM = Math.pow(10.0, exp); this will return distance in meter. i got these code by reserch on google from many pages. but i think i am

postgis distance between two points on a line

空扰寡人 提交于 2019-12-03 09:10:02
I have a route (as a LINESTRING) and two vehicles with a position (as a POINT). I need to calculate the distance between the two points over the route. As an added difficulty I think I also need to measure the distance from the point to the closest point on the line in the case that the vehicle is not on the route at that moment. I'm using this to find the closest point on the route: SELECT ST_AsText(ST_ClosestPoint(pt,line)) AS cp_pt_line, ST_AsText(ST_ClosestPoint(line,pt)) As cp_line_pt FROM (SELECT 'POINT(100 100)'::geometry As pt, 'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry As

Distance from Lat/Lng point to Minor Arc segment

喜你入骨 提交于 2019-12-03 08:52:08
问题 I need to calculate the shortest distance from a lat/lng GPS point P to a line segment described by 2 other lat/lng GPS points A and B. 'Cross-track distance' helps me to calculate the shortest distance between P and the great circle described by A and B. However, this is not what I want. I need need the distance between P and the line segment of A-B, not the entire great circle. I have used the following implementation from http://www.movable-type.co.uk/scripts/latlong.html Formula: dxt =

Manhattan Distance for two geolocations

半腔热情 提交于 2019-12-03 08:42:51
Let's say I have two locations represented by latitude and longitude. Location 1 : 37.5613 , 126.978 Location 2 : 37.5776 , 126.973 How can I calculate the distance using Manhattan distance ? Edit : I know the formula for calculating Manhattan distance like stated by Emd4600 on the answer which is |x1-x2| - |y1-y2| but I think it's for Cartesian. If it is can be applied that straight forward |37.5613-37.5776| + |126.978-126.973| what is the distance unit of the result ? Given a plane with p1 at (x1, y1) and p2 at (x2, y2) , it is, the formula to calculate the Manhattan Distance is |x1 - x2| +

How do I manipulate/access elements of an instance of “dist” class using core R?

孤街浪徒 提交于 2019-12-03 08:36:07
问题 A basic/common class in R is called "dist" , and is a relatively efficient representation of a symmetric distance matrix. Unlike a "matrix" object, however, there does not seem to be support for manipulating an "dist" instance by index pairs using the "[" operator. For example, the following code returns nothing, NULL , or an error: # First, create an example dist object from a matrix mat1 <- matrix(1:100, 10, 10) rownames(mat1) <- 1:10 colnames(mat1) <- 1:10 dist1 <- as.dist(mat1) # Now try

Is Triangle inequality necessary for kmeans?

扶醉桌前 提交于 2019-12-03 08:33:25
I wonder if Triangle inequality is necessary for the distance measure used in kmeans. k-means is designed for Euclidean distance, which happens to satisfy triangle inequality. Using other distance functions is risky, as it may stop converging . The reason however is not the triangle inequality, but the mean might not minimize the distance function . (The arithmetic mean minimizes the sum-of-squares, not arbitrary distances!) There are faster methods for k-means that exploit the triangle inequality to avoid recomputations. But if you stick to classic MacQueen or Lloyd k-means, then you do not