Let's suppose I have the following data points on Earth:
var startPoint = [51.263969,-0.527153]
var endPoint = [51.258813,-0.505876]
var vector = [startPoint,endPoint]
var metres = 100
So the startPoint and endPoint represent a vector along the globe. What I need to do is find a new point which represents a point 100 metres away from endPoint in the direction of the vector.
How can I do this?
I've found some algorithms to move a lat/long by a number of metres, but they don't take into account an angle. I've also had a look through C# libraries such as DotSpatial but can't find anything to do this.
Bonus points for a C# library which can do this! But I'm happy to implement this myself if necessary.
Note: This should be calculated on a 3D spherical plane, example: Earth
Related
As the title suggests, I am trying to generate a coordinate based on another coordinate that is within an x mile (or whichever unit is most convenient) radius of the inputted one.
As an example:
I am given a geographic coordinate (lat, lon) of 39.083056, -94.820200.
I want to be returned another set of coordinates that is within a x
miles radius of that coordinate, such as 39.110998, -94.799668.
The x mile radius isn't as important as the fact that the returned
coordinates are within that x mile radius.
I have searched and searched, but I must be searching the wrong thing because all the posts that I have been able to find seem like they get very close to what I am trying to do but aren't quite hitting the nail on the head.
I'm sorry you're being downvoted to oblivion. I understand it can be frustrating trying to search for something without knowing what exactly to search for.
You may be interested in Orthodromic Lines/Distances: wiki. If this answer doesn't fulfil your needs, at least you have a new term to google and hopefully will lead you to one that does suit.
You could try using the Geo library. Its documentation is on the sparse side, but it does contain a method that could be useful to you: CalculateOrthodromicLine(startPoint, heading, distance)
A pseudocode would be something as simple as this:
var startPoint = new Coordinate(lat, long);
var heading = Random between 0 and 360 degrees
var distance = Random between 0 and X metres
var endPoint = //<-- et voila!
GeoContext.Current.GeodeticCalculator
.CalculateOrthodromicLine(startPoint, heading, distance)
.Coordinate2;
Edit: As mentioned in the wiki, the Earth is not a perfect sphere, but a spheroid instead. The library's GeoContext.Current by default uses its Spheroid calculations, so you should be okay.
Good luck!
I actually measured (x,y) joint position that related to a human skeleton in the sagittal plan using Kinect v2 camera. Now, I want to create the angle between Kinect v2 and skeleton direction of motion( like in this figure: http://www.mediafire.com/file/7wf8890ngnmi1d4/kinect.pdf ).
How can I measure the joint position relative to a coordinate fixed on certain join on the skeleton like SpineBase position using MATLAB??
what is the transformation required to do that?
I have no kinect available right now, but here is the theory how I would tackle this:
First of you seem to already be able access the different joint coordinates, so you have sth like this:
if (body.IsTracked)
{
Joint spineMid = body.Joints[JointType.SpineMid];
float x = spineMid.Position.X;
float y = spineMid.Position.Y;
float z = spineMid.Position.Z;
}
This gives us a spineMid point with x,y,z. Each frame we compare that spineMid point to the spinMid point from last frame (and save it afterwards for the comparison in the next frame). Lets call these points P_new and P_old. To get the direction Vector we just subtract the two like so:
p_dir = P_new - P_old
now we have to get the angle between this direction vector and the vector "out" of the kinect which is <0,0,1> with the kinect coordinate system. But given your drawing we need to use z_dir = <0,0,-1>.
By using the unit vector of p_dir, lets call it p_dir_unit, we can use the dot product to get the angle between z_dir and p_dir_unit.
theta = acos(z_dir * p_dir_unit)
If you only need the direction in the x,z plane, you can just set the y value for p_dir to 0 and get the unit vector from that vector. From the absolute length of p_dir you can also get information on how quick the body is moving.
Hope that helps.
Sorry if this has been asked before, but I couldn't find a valid response or a response I could understand
Currently I have a code that draws a line from a Joint to Joint in the Kinect, this forms the Bone:
drawingContext.DrawLine(drawPen, jointPoints[jointType0], jointPoints[jointType1]);
In the picture aboe it shows Parallel lines joining from circle to cirlce, Can someone please explain to me or show me to create these lines?
If you have a line from point p0 to point p1, and want to create a parallel line / offset line, you need to use either trigonometry or vector math.
To do it using vector math:
Find the direction vector of the line
Find a vector perpendicular to that
Use the perpendicular vector to offset p0 and p1
Pseudo code:
Vector vLine = ( p1 - p0 ).Normalized();
Vector vPerp = new Vector( -vLine.Y, vLine.X );
Point newp0 = p0 + vPerp * offset distance
Point newp1 = p1 + vPerp * offset distance
DrawLine( newp0, newp1 );
Reverse the offset or negate vPerp to get a line on the other side. How you do this depends on what you have available. System.Windows.Vector and System.Windows.Point should work fine since you're using WPF.
If you are interested in what's going on here in more detail, get your googling on and search for vector math or linear algebra.
I have a current position: Latitude and Longitude values in degrees (Point A), and the same for the final position (Point B).
I need to calculate the course (also in degrees) between the two points and than with given speed (in km/s) and timespan (in seconds) to calculate the new position.
Example (Pseudo code):
PointA.Lat = x.xxxx;
PointA.Lng = x.xxxx;
PointB.Lat = x.xxxx;
PointB.Lng = x.xxxx;
Speed = 3;
TimeSpan = 0.1;
Course = GetCourse(PointA, PointB);
NewPoint = CalculatePoint(PointA, Course, Speed, TimeSpan);
I thought of using the GeoCoordinate class, but I'm not sure how ad I have to implement myself all the calculations. (I don't have a GPS - this is only a simulation and those are fake points).
Can someone help me with the math or with some package that can do it free and can easly be intagrated to my code?
BTW I'm using C#.
Thanks.
I'd have made this a comment but I don't have the required rep.
What you're looking for is a geodesy library that gives you the “geodetic inverse” and “geodetic direct” calculations. I don't know of any myself, but try searching for “c# geodesy library”
The former gives the bearing and distance between two geographical coordinates, the latter gives a new coordinate at a given bearing and distance from the first.
So for your problem:
Use the inverse to get the bearing between PointA and PointB
Calculate a destination distance from the time and speed,
Plug the bearing and distance into the direct to get the desired destination NewCoord.
Coding these calculations from 1st principles will be quite substantial and require the parameters of (presumably) the WGS84 ellipsoid. This, however, is the starting point.
Hope this helps.
I'm doing a project on radar simulation and i have to detect how fast a plane is flying using c#.
Is there a formula which I can use to calculate the distance and the speed?
See the picture, R is the radar, P1 is the plane position at time 0, P2 is the plane position after time t. Since we know the speed of the radar wave in the air, we can calculate RP1 and RP2 easily. Also the angle P1RP2 is known, we can get length of P1P2 by trigonometric function. so the speed of the plane is P1P2/t.
There are different ways to determine the speed via radar. the one already mentioned, but also the change of frequency.
you might wanne check this out:
http://en.wikipedia.org/wiki/Doppler_radar
the distance between plane and radar is a result of the time used between transmitting and receiving.
d = c*t/2
If you have two know two points where the plane has been, and the time difference between these references, then it is very possible.
Speed it easy, calculate the distance usin g pythagorus:
float dist = sqrt( sqr(x2-x1) + sqr(y2-y1) );
Direction is trickier, and requires some trig. Try searching the internet for the formula for direction between two points.