Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate new coordinates from old coordinates and x and y

I have the following setup of items in real life:

My setup

The radar is static, which means it always has the same position. The A-item can move and its position can be whatever. From the radar I can read the x and y coordinates of A in relation to the radar. I have written the following classes to describe the position of each item:

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 facing 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 an issue since the maximum value of x and/or y cannot be more than a couple hundred meters.

like image 821
Dimme Avatar asked Mar 12 '13 18:03

Dimme


2 Answers

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

Example of using trigonometric functions

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

This way, you are never stuck in degrees, you are simply working in meters.

The robust solution is Vishal's comment in the OP, which was posted whilst I was drawing and scanning:

xnew = x * cos(theta) - y * sin(theta); 
ynew = x * sin(theta) + y * cos(theta);
like image 198
J.T. Taylor Avatar answered Sep 29 '22 10:09

J.T. Taylor


In general, you can use the following steps:

  1. transform your radar position (lat, lon, height) into metric earth centered earth fixed xyz-system (ECEF)
  2. You can then use/combine any rotation and translation arguments/matrices, which describe radar rotation and object position, in this metric system
  3. back transform newly acquired xzy coordinates to lat/lon/h

There are many ressources for such transformations, check this, for instance: http://www.gmat.unsw.edu.au/snap/gps/clynch_pdfs/coordcvt.pdf

You can also introduce a scene coordinate system, if needed (ENU). Here is a fairly good overview describing the relation of UTM, ECEF, ENU and geodotic coordinates(Lat/lon/h): http://www.dirsig.org/docs/new/coordinates.html

If you need sample code for ECEF to/from Geodetic conversion, have a look at the matlab code, http://www.mathworks.de/de/help/map/ref/ecef2geodetic.html, or use a library like GDAL (http://www.gdal.org/)

like image 32
DomTomCat Avatar answered Sep 29 '22 10:09

DomTomCat