Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think it should be possible to do it this way: Convert the <code>x</code> and <code>y</code> coordinates to polar coordinates <code>r</code> and <code>theta</code>, (with the radar as the origin). Subtract the radar's rotation, and convert back to cartesian coordinates. Then you just have to convert to latitude and longitude and add the coordinates of the radar.</p> <pre><code>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; </code></pre> <p>I found formulae for the length of a degree of latitude and longitude on Wikipedia. A degree of latitude is the same everywhere but longitude gets smaller near the poles.</p> <pre><code>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)); } </code></pre> <p>Unfortunately this doesn't seem to work and I can't figure out why.</p> <p>If you want to express your coordinates in positive degrees east/west/north/south you'll also have to check if they're negative and invert them and the direction in that case.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload