distance

How to calculate distance based on phone acceleration

佐手、 提交于 2019-11-30 06:20:53
问题 I want to build something like this but using an android phone: http://www.youtube.com/watch?v=WOt9mb5QqRs I've already built an app that sends sensor information via socket (still looking for a good websocket implementation for android). I intend to use that information to interact with a web app, so for example i would be able to move an image based on the phone movement. The problem is that I tried to calculate distance based on the accelerometer data but the results are really bad. I

Camera focus distances

岁酱吖の 提交于 2019-11-30 04:54:15
I'm trying to read the focus distance (distance of subject in a photo) from an Android camera. I keep getting 0 for all focus distances on my HTC Desire even when it correctly autofocuses. Here's the whole app, only works on v2.3.3 and above. ImageCapture.java package test.test; import java.io.IOException; import java.io.OutputStream; import java.text.SimpleDateFormat; import android.app.Activity; import android.content.Intent; import android.graphics.PixelFormat; import android.hardware.Camera; import android.hardware.Camera.AutoFocusCallback; import android.hardware.Camera.PictureCallback;

How can I measure diagonal distance points?

偶尔善良 提交于 2019-11-30 04:37:37
问题 I can compute horizontal and vertical points, but I cant figure out how to compute distance using diagonal points. Can someone help me with this. here's the code for my horizontal and vertical measuring: private float ComputeDistance(float point1, float point2) { float sol1 = point1 - point2; float sol2 = (float)Math.Abs(Math.Sqrt(sol1 * sol1)); return sol2; } protected override void OnMouseMove(MouseEventArgs e) { _endPoint.X = e.X; _endPoint.Y = e.Y; if (ComputeDistance(_startPoint.X,

Computing sparse pairwise distance matrix in R

人走茶凉 提交于 2019-11-30 03:08:46
I have a NxM matrix and I want to compute the NxN matrix of Euclidean distances between the M points. In my problem, N is about 100,000. As I plan to use this matrix for a k-nearest neighbor algorithm, I only need to keep the k smallest distances, so the resulting NxN matrix is very sparse. This is in contrast to what comes out of dist() , for example, which would result in a dense matrix (and probably storage problems for my size N ). The packages for kNN that I've found so far ( knnflex , kknn , etc) all appear to use dense matrices. Also, the Matrix package does not offer a pairwise

How can I determine the distance between two sets of latitude/longitude coordinates?

十年热恋 提交于 2019-11-30 02:56:18
问题 I am trying to write something that will determine the distance between to sets of lat/lon coordinates. I am using the following code which I found on this site: public static double distance (double lat1, double lon1, double lat2, double lon2) { double lat1 = Convert.ToDouble(latitude); double lon1 = Convert.ToDouble(longitude); double lat2 = Convert.ToDouble(destlat); double lon2 = Convert.ToDouble(destlon); double theta = toRadians(lon1-lon2); lat1 = toRadians(lat1); lon1 = toRadians(lon1)

Math Calculation to retrieve angle between two points? [duplicate]

為{幸葍}努か 提交于 2019-11-30 02:44:41
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to calculate the angle between two points relative to the horizontal axis? I've been looking for this for ages and it's just really annoying me so I've decided to just ask... Provided I have two points (namely x1, y1, and x2, y2), I would like to calculate the angle between these two points, presuming that when y1 == y2 and x1 > x2 the angle is 180 degrees... I have the below code that I have been working

Minimum distance between a point and a line in latitude, longitude

北城以北 提交于 2019-11-30 02:21:56
I have a line with two points in latitude and longitude A: 3.222895, 101.719751 B: 3.227511, 101.724318 and 1 point C: 3.224972, 101.722932 How can I calculate minimum distance between point C and a line consists of point A and B? It will be convenient if you can provide the calculation and objective-c code too. The distance is around 89 meters (using ruler in Google Earth). Azam Thanks to mimi and this great article http://www.movable-type.co.uk/scripts/latlong.html but they don't give the whole picture. Here is a detail one. All this points are collected using Google Earth using Placemark to

How can i calculate the distance between two gps points in Java?

浪尽此生 提交于 2019-11-30 01:40:41
I used this code but it doesnt work: Need the distance between two gps coordinates like 41.1212, 11.2323 in kilometers (Java) double d2r = (180 / Math.PI); double distance = 0; try{ double dlong = (endpoint.getLon() - startpoint.getLon()) * d2r; double dlat = (endpoint.getLat() - startpoint.getLat()) * d2r; double a = Math.pow(Math.sin(dlat / 2.0), 2) + Math.cos(startpoint.getLat() * d2r) * Math.cos(endpoint.getLat() * d2r) * Math.pow(Math.sin(dlong / 2.0), 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double d = 6367 * c; return d; } catch(Exception e){ e.printStackTrace(); }

How to get speed in android app using Location or accelerometer or some other way

Deadly 提交于 2019-11-30 00:59:32
I am working on app and try to get the speed and distance travelled by the user. I have used Google Play services location class to get the speed but it always returns me 0.0 value and not at all reliable. I wan accurate speed and distance travelled at real time. I have installed GPS Speedometer app on my device and its so perfect that even if i am walking then it gives me the speed. I want to get the same thing. I am confused in how to get speed, using location or using accelerometer or is there any other way to do it? My code is available on this link :- Drawing route on Google Maps using

tableview sort by distance swift

眉间皱痕 提交于 2019-11-29 23:59:09
问题 I build a view mix with map view and table view,I hope I can sort the cell by the distance from user location, I try to use the distanceFromLoaction method, but it shows that CLLocationCoordinate has no member distanceFromLocaiton, is there another way to do it or fix it? this is my array structure import UIKit import MapKit class tripSpot: NSObject, MKAnnotation{ var title: String? var coordinate: CLLocationCoordinate2D var regionRadius: Double var location: String? var type: String? init