How to Calculate new location with distance and bearing - android-location

I am wondering if there is a simple way to manually change a android.location to be one meter away from a given bearing.
Lets say i have two locations and i get the bearing by saying:
location1.bearingTo(location2)
and i have a static distance traveled of 1 meter..
how would i go about saying:
location1 = //1 meter from location1 at bearing
I am wondering if there is a built in method for android.location that does this.. I looked and didn't see one, but maybe i am just missing it.. or if anyone can point me in the right direction for figuring out the math

There are two built-in methods that I know of:
Using SphericalUtil:
SphericalUtil.computeOffsetOrigin(startLocation, distance, bearing);
Using OsmDroid:
GeoPoint startLocation = ...;
startLocation.destinationPoint(distance, bearing);

Related

How to interpolate an NSBezierPath/UIBezierPath and retrieve normal Vector at location?

I have an NSBezierPath. I would like to interpolate along in a way that
interpolate (0) = starting point
interpolate (1) = end point
interpolate (0.5) = middlePoint.
I would like as well a function that provides a normal vector at the point.
I saw a lot of puzzle pieces during my search but nobody offering a full solution in swift. Key problems are:
how can I ensure that interpolate(0.5) is really in the middle of the path? Do I need to consider the length of the overall path? Will it always be the middle point of the middle path segment? I doubt that. However, good approximations are welcome!
how do I retrieve the normal vector on such a point?
Many thanks in advance!
Basically, I used this library: https://github.com/louisdh/bezierpath-length/blob/master/Source/BezierPath%2BLength.swift
It gave me a good approximation of the x that is needed in order to do the interpolation after a small change. With that x and this explanation: https://medium.com/#adrian_cooney/bezier-interpolation-13b68563313a was I able to find the normal vector (the last interpolation is along the tangent, so I only needed the orthogonal vector from that last interpolation).
My code is still a bit messy. I might publish later. But it works!

Xamarin.Forms: how to get driving distance between two points?

My app currently uses Location Services. During debugging, I retrieve my current location using GetLastKnownLocationAsync: myposition.Latitude is 40.758896 while myposition.Latitude is -73.985130.
My SQL Database has a list of Walmart stores, and there's a Walmart with Latitude & Longitude of 40.660992 & -73.7267629.
How can I calculate the driving distance between my set of coordinates and Walmart's coordinates? It would be something like Google Maps' Driving Directions or Waze.
I understand that I can use this SO link to calculate the distance between two sets of point, but I assume apps like Google Maps or Waze consider the actual driving distance between two sets of points. The link above would be great if there were a straight street between two points. Obviously, that's not the case.
I have used Xamarin.Essential library to find the distance between two point
You can use something like this
var location = new Location(21.705723, 72.998199);
var otherLocation = new Location(22.3142, 73.1752);
double distance = location.CalculateDistance(otherLocation,DistanceUnits.Kilometers);

How do I include today in the time axis in Rickshaw

I'd look this up in Rickshaw's documentation if it had any. Does it?
I want my time axis to include the current date, even if there isn't a point there. I already worked around this by duplicating the last data point, but I'd prefer if that point didn't show up as a point in the hover-highlighter. Perhaps that's something I can override differently?
Speaking of points, can I get it to draw the points even if I'm using the area renderer?

Triangulation From Two Points To Find The Coordinates Of The Third

Seeking guidance on The topic. Must I really create what I'm sure is all ready out there.
I'm simply looking for a basic program to throw on a garmin that will allow me: to create a way point using a GPS, log azimuth from said point. Travel to new location create way point using a GPS, log azimuth from said point then have gps give me coordinates of the cross thus allowing me to relay location of third point with out actually having to travel to point.
It seems that you need Intersection of two paths given start points and bearings section from this excellent page.
I'm not sure that the formatting will remain when copying text here, so I'll insert a picture:

Reach a waypoint using GPS/Compass/Accelerometer - Algorithm?

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

Resources