I want to use ML pack distance metrics to evaluate distance.
I have two arma:vec. Need to find distance between the two vec.
mlpack::metric::EuclideanDistance distance();
cout<<distance.Evaluate(temp_vec2, temp_vec2);
Not sure how to use this.
mlpack::metric::EuclideanDistance distance;
instead of
mlpack::metric::EuclideanDistance distance();
works
Related
I am struggling with DWithin queries in geomesa.
I have ingested many geo points from OSM and want to make DWithin queries.
I have the following code for query:
val query = new Query("t1", ECQL.toFilter("DWITHIN(geo_point, POINT (14.453943 60.499611), 5000, meters)"))
I expect geomesa to answer with the points not far then 5000 meters from POINT (14.453943 60.499611) (points 2,3,4 on the map).
But geomesa gives me more points than expected.
All the points in the map (1,2,3,4,5,6) are returned for this query.
It seems that geomesa can't properly filter out the points for DWithin query since it does not have support for geodesic distance checks.
So, is there any way to make DWITHIN query work correctly (in a geodesic manner) with geomesa?
Thanks!
GeoMesa uses the geotools dwithin filter function for such queries. Unfortunately, the function only supports native distances (i.e. degrees in WGS84).
Currently, your best bet is to use the geotools GeodeticCalculator class to create a polygon covering your query area and use that in an intersects filter. Alternatively, you could post-filter the results using the Geodetic Calculator.
Going forward, I've created a ticket to handle this use case better in GeoMesa: https://geomesa.atlassian.net/browse/GEOMESA-2263
I need to get travel time by plane between two locations.
In Distance Matrix API there is no Travel Mode like "flight" - https://developers.google.com/maps/documentation/javascript/distancematrix#travel_modes
Any suggestions?
Unfortunately there is no easy way to do this.
However, you could do a trick and estimate the flight time by using geocoding and the geometry library. At least if you don't need real flight data.
The steps would be:
Transform origin and destination from String to LatLng (Geocoding API)
Create markers for each location. (Geometry lib)
Calculate airline distance using computeDistanceBetween (like this: google.maps.geometry.spherical.computeDistanceBetween(path1, path2))
Calculate approximate flight time using average airplane speed.
Hope this helps.
This is sort of a work-around, but an easy one.
Use the measure distance tool in google maps, then for flight time of regular commercial airliners, divide the distance in miles by 500mph to get flight time in hours. For a small propeller plane (like a cessna), use 165mph.
Hy!
I have organized point clouds from a Kinect sensor. Let's say I have a organized point cloud of a sofa with a table in front. What I would like the get are two clouds: sofa and table
I am searching for some algorithm to get the connected components.
Does anyone have some pseudo code or papers? Or maybe some code (Matlab)
My idea at the moment: I could use the 2D information to get neighboring pixels of a point.
Next I could check the euclidean distance to the neighboring pixels. If the distance is below a threshold, the pixel belongs to the same cluster. ...
Thanks
As #Amro pointed out, DBSCAN is the algorithm you should study. It is a clustering based on ''density-connected'' components.
Also note the GDBSCAN variant (Generalized DBSCAN). You are not restricted to primitive distances such as Euclidean, but you can make your "neighborhood" definition as complex as you'd like.
Matlab probably is not the best choice. For DBSCAN to be really fast, you need support for index acceleration. Recent scikit-learn (0.14 to be precise) just got basic index acceleration for DBSCAN, and ELKI has had it for years. ELKI seems to be more ''flexible'' wrt. to having GDBSCAN and having index structures that are easy to extend with custom distance functions. sklearn probably only accelerates a few built-in distances.
you can use the connected component segmentation plugin from "Tools>Segmentation>label connected component" from cloudcompare software
What will be the best way (or) Is there a Google's way already to Calculate the simple Straight Line Distance between Two Points, based on Lat/Lng or even on Postal/Zip Code is possible?
I found the answer by myself, from somewhere else.
Yes, there is a native solution from Google already, at:
https://developers.google.com/maps/documentation/javascript/reference?hl=en-US#spherical
All I need to do is to call the method:
'google.maps.geometry.spherical.computeDistanceBetween (latLngA, latLngB);'
(Ofcourse I also need to include the additional/required '.js')
"Best" is a pretty vague criterion. If you're able to assume the earth is a perfect sphere, then you want the simple formula for great circle distance. See for example the Wikipedia article. With this assumption your distance can be off by something less than half a percent.
The actual shape of the earth is actually a slightly oblate spheroid. The surface distance on this shape is more complicated to compute. See Ed Williams' work in javascript. Maybe he will let you use his code. If not he gives relevant references.
A free solution is at http://ezcmd.com/apps/app_ezip_locator#ezip_locator_api
Can help you find distance between two lat,long coordinates in miles or Km.
Or, you could try http://ezcmd.com/apps/app_geo_postal_codes#geo_postal_codes_api
The "best" way depends on several things. Can you provide a little more background as to how accurate and/or what's the desired application? The google.maps.DirectionsService class will allow you to calculate the driving distance client side with javascript, but if you want an accurate straight line distance you could use postgresql + postgis server side. Calculating accurate distances with lat/lng can get tricky with the different projections of the earth depending on the range of points and distances involved.
I currently have a robot with some sensors, like a GPS, an accelerometer and a compass. The thing I would like to do is my robot to reach a GPS coordinate that I enter. I wondered if any algorithm to do that already existed. I don't want a source code, which wouldn't have any point, just the procedure to follow for my robot to do so, for me to be able to understand what I do... At the moment, let's imagine that I can access the GPS coordinate everytime, so no need of a Kalman filter. I know it's unrealistic, but I would like to programm it step by step, and Kalman is the next step.
If anyone has an idea...
To get a bearing (positive angle east of north) between two lat-long points use:
bearing=mod(atan2(sin(lon2-lon1)*cos(lat2),(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1)),2*pi)
Note - angles probably have to be in radians depending on your math package.
But for small distances you can just calculate how many meters in one degree of lat and long at your position and then treat them as flat X,Y coords.
For typical 45deg latitudes it's around 111.132 km/deg lat, 78.847 km/deg lon.
1) orient your robot toward its destination.
2) Move forward until the distance between you and your destination is increasing where you should go back to 1)
3) BUT ... if you are close enough (under a threshold), consider that you arrived at the destination.
You can use the Location class. It's BearingTo function computes the bearing you have to follow to reach another location.
There is a very nice page explaining the formulas between GPS-based distance, bearing, etc. calculation, which I have been using:
http://www.movable-type.co.uk/scripts/latlong.html
I am currently trying to do these calculations myself, and just found out that in Martin Becket answer there is an error. If you compare to the info of that webpage, you will see that the part in the middle:
(lat1)*sin(lat2)
should actually be:
cos(lat1)*sin(lat2)
Would have left a comment, but don't have the reputation yet...