Calculate new coordinates from old coordinates and x and y

I have the following settings for elements in real life:

My setup

The radar is static, which means that it always has the same position. Element A can move, and its position can be any. From the radar, I can read the x and y A coordinates relative to the radar. I wrote the following classes to describe the position of each element:

 public class Position { public enum Direction { EAST, WEST, NORTH, SOUTH }; public final Direction latitudeDirection, longitudeDirection; public final float latitude, longitude, altitude; public Position(Direction latitudeDirection, Direction longitudeDirection, float latitude, float longitude, float altitude) { this.latitudeDirection = latitudeDirection; this.longitudeDirection = longitudeDirection; this.latitude = latitude; this.longitude = longitude; this.altitude = altitude; } public Position(float radarX, float radarY) { // TODO: Implement the question here this.altitude = Config.RADAR_POSITION.altitude; } } class Config { // Position of the radar public static final Position RADAR_POSITION = new Position( Position.Direction.NORTH, // Latitude direction Position.Direction.EAST, // Longitude direction 55.0f, // Latitude 13.0f, // Longitude 60.0f); // Altitude // Facing direction of the radar in degrees. 0° is north, advancing // clockwise. public static final float RADAR_FACING_DIRECTION = 10.0f; } 

Now, given the geographic coordinates of the radar, the x and y coordinates of A relative to the radar, and the reverse direction of the radar relative to the North, how can I calculate the absolute geographic coordinates of A ?

The curvature of the earth is not a problem, since the maximum value of x and / or y cannot be more than a couple of hundred meters.

+7
source share
6 answers

I think this can be done like this: convert the x and y coordinates to the polar coordinates r and theta (with radar as a source). Subtract the rotation of the radar and convert back to Cartesian coordinates. Then you just need to convert to latitude and longitude and add the coordinates of the radar.

 double r = Math.hypot(radarX, radarY); double theta = Math.atan2(radarY, radarX); theta -= Math.toRadians(Config.RADAR_FACING_DIRECTION); float x = (float) r * Math.cos(theta); float y = (float) r * Math.sin(theta); longitude = metersToLongitude(Config.RADAR_POSITION, y) + Config.RADAR_POSITION.longitude; latitude = metersToLatitude(Config.RADAR_POSITION, x) + Config.RADAR_POSITION.latitude; 

I found formulas for degree degrees of latitude and longitude on Wikipedia. The degree of latitude is the same everywhere, but the longitude becomes less at the poles.

 static float metersToLatitude(Position near, float meters) { return meters / 110.6*1000; } static float metersToLongitude(Position near, float meters) { float lat = Math.toRadians(near.latitude); return meters / (111132.954 - 559.822 * Math.cos(2*lat) + 1.175 * Math.cos(4*lat)); } 

Unfortunately, this does not work, and I cannot understand why.

If you want to express your coordinates in positive degrees east / west / north / south, you will also need to check if they are negative and invert them and direction in this case.

+1
source

As an example, you can use trigonometric functions to create triangles to find the coordinates of A:

Example of using trigonometric functions

In this case, Ax = (y) (cos 10) - (x) (cos 80), and you can also work out Ay.

This way you are never stuck in degrees, you just work in meters.

A reliable solution is the Vishal comment in OP, which was published during drawing and scanning:

 xnew = x * cos(theta) - y * sin(theta); ynew = x * sin(theta) + y * cos(theta); 
+3
source

In general, you can use the following steps:

  • converts your radar position (lat, lon, height) into a metric grounded xyz system with ground (ECEF)
  • Then you can use / combine any rotation and translation / matrix arguments that describe the rotation of the radar and the position of the object in this metric system.
  • back convert newly received xzy coordinates to lat / lon / h

There are many resources for such conversions, check this out, for example: http://www.gmat.unsw.edu.au/snap/gps/clynch_pdfs/coordcvt.pdf

You can also enter a scene coordinate system if necessary (ENU). Here is a pretty good overview describing the relationship of UTM, ECEF, ENU and geodetic coordinates (Lat / lon / h): http://www.dirsig.org/docs/new/coordinates.html

If you need sample code for ECEF to / from geodetic conversion, see matlab code, http://www.mathworks.de/de/help/map/ref/ecef2geodetic.html , or use a library such as GDAL ( http : //www.gdal.org/ )

+2
source
+1
source
I finally decided. The code is attached below. Since the answer of Samuel Edwin Ward is the one that inspired me, I will accept his answer.
 public Position(float radarX, float radarY) { // Convert A position to distance and bearing in relation to the North double objDistance = (Math.hypot(radarX, radarY) / 6367500 /* Mean earth radius */); double objBearing = (Math.atan2(radarY, radarX) + Math.toRadians(Config.RADAR_BEARING)); // Convert the Radar geographic coordinates to radians double latitudeRadar = Math.toRadians(Config.RADAR_POSITION.latitude); double longitudeRadar = Math.toRadians(Config.RADAR_POSITION.longitude); // Calculate A geographic coordinates in radians double latitudeObject = Math.asin(Math.sin(latitudeRadar)*Math.cos(objDistance) + Math.cos(latitudeRadar)*Math.sin(objDistance)*Math.cos(objBearing)); double longitudeObject = longitudeRadar + Math.atan2(Math.sin(objBearing)*Math.sin(objDistance)*Math.cos(latitudeRadar), Math.cos(objDistance)-Math.sin(latitudeRadar)*Math.sin(latitudeObject)); // Normalize to -180 ... +180 degrees longitudeObject = (longitudeObject+3*Math.PI) % (2*Math.PI) - Math.PI; // Set the A coordinates in degrees this.latitude = (float) Math.toDegrees(latitudeObject); this.longitude = (float) Math.toDegrees(longitudeObject); // Set the rest of the arguments this.latitudeDirection = Config.RADAR_POSITION.latitudeDirection; this.longitudeDirection = Config.RADAR_POSITION.longitudeDirection; this.altitude = Config.RADAR_POSITION.altitude; } 
+1
source

You rotate all the coordinates in the local radar system -10 ° and then you can simply add the x / y coordinates of the radar to the coordinates of object A.

0
source

All Articles