在圆形雷达数学方法上表示点 [英] Representing Points on a Circular Radar Math approach

查看:18
本文介绍了在圆形雷达数学方法上表示点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个简单的应用程序,它可以向您展示您周围的朋友,但不是在法线地图中,而是在像 UI 一样的真正圆形雷达上:

(是构建 4x4 变换矩阵背后的数学运算

  • 此处您可以看到同构 4x4 和直接 3x3 3D 变换矩阵和数学之间的图像差异
  • 将所有点转换为 RADAR 坐标系

    只需将所有点乘以RADAR变换矩阵M

    Q(i) = P(i)*M

    所以点 Q(i) 现在是 RADAR

    的本地点
    • (0,0,0) 表示雷达原点(中心)
    • (1,0,0) 指向北
    • (0,1,0) 指向东
    • (0,0,1) 指向上

    所以现在只需将所有坐标乘以雷达比例

    scale = RADAR_radius/RADAR_range;

    • RADAR_radius 是您RADAR在屏幕上的大小,以像素或坐标单位为单位
    • RADAR_rangeRADAR最大圆圈代表的最大距离[m]

    在此之后只需将点绘制到 RADAR(交换 x,y 因为我使用 X 作为北而不是 Y) 并且您也可以丢弃所有比范围更远的点.您也可以像旧的 Elite 一样添加 3D RADAR,方法是将 Z 坐标添加到垂直轴(或画一条 L 线)

  • 希望它有点帮助,不要太混乱......

    I am coding a simple app that can show you what friends are around you, but not in the normal map but on a really circular radar like UI:

    (http://i.imgur.com/9Epw0Xh.png)

    Like this, where i have every users latitude, longitude, and of course my own being the center.

    I also measure the distance of every user to position them so the data I know is their lat, longitude and distance to me.

    For mathematical reasons let's say the radar is 100 pixels radius, I can distance them by the distance from me using the left or right positioning, but in terms of top or bottom it gets a litte trickier, since i try to convert their latitude - my latitude into a percentual result and then put them on the radar... but I think there are maybe better ways with polar to cartesian coordinates, but im really kinda clueless.

    Is there a best approach with these types of interfaces or anything implemented around there?

    解决方案

    1. convert long,lat of all points to cartesian 3D space coordinates

      it is conversion spherical -> cartesian 3D space. Math behind is here. After this all points (long,lat,alt) will became (x,y,z) where (0,0,0) is center of the Earth

      • X axis is lat=0,long=0 [rad]
      • Y axis is lat=0,long=+PI/2 [rad]
      • Z axis is North
      • XY plane is equator

      If you want more precision handle Earth as ellipsoid instead of sphere

      long = <     0 , +2*PI > [rad]
      lat  = < -PI/2 , +PI/2 > [rad]
      alt  = altitude above sea level [m]
      Re =6378141.4; [m]
      Rp =6356755.0; [m]
      
      R=alt+sqrt( (Re*cos(lat))^2 + (Rp*sin(lat))^2 )
      x=R*cos(lat)*cos(long)
      y=R*cos(lat)*sin(long)
      z=R*sin(lat)
      

    2. create RADAR local cartesian coordinate system

      Basically you need to obtain 3D vectors for X,Y,Z axises. They must be perpendicular to each other and pointing to the right direction from RADAR origin point (P0).

      You can use vector multiplication for that because it creates perpendicular vector to its multiplicants. Direction is dependent on the order of multiplicants so experiment a little.

      //altitude this one is easy
      Z = P0
      //north (chose one that is non zero, resp. bigger to avoid accuracy problems)
      X = (1,0,0) x Z // old X axis * Altitude
      X = (0,1,0) x Z // old Y axis * Altitude
      //east is now also easy
      Y = X x Z 
      // now normalize all of them to unit vectors
      X = X / |X|
      Y = Y / |Y|
      Z = Z / |Z|
      // and check if they are not negative (X,Y)
      // if they are then swap multiplicants or multiply by -1
      // do not forget that X is computed by two methods so swap the correct one
      

      • here is math behind constructing an 4x4 transform matrix
      • here you can see on an image difference between homogenous 4x4 and direct 3x3 3D transform matrices and math
    3. convert all points to RADAR coordinate system

      just multiply all points by RADAR transform matrix M

      Q(i) = P(i)*M
      

      so the points Q(i) are now local to RADAR

      • (0,0,0) means radar origin (center)
      • (1,0,0) points to north
      • (0,1,0) points to east
      • (0,0,1) points up

      so now just multiply all cordinates by RADAR scale

      scale = RADAR_radius/RADAR_range;
      

      • RADAR_radius is size of you RADAR on screen in pixels or units of coordinates
      • RADAR_range is the max distance the RADAR biggest circle represents [m]

      after this just draw the dot to RADAR (swap x,y because I use X as North not Y) and also you can discard all points that are more distant then range. Also you can add 3D RADAR like in old Elite by adding Z coordinate to vertical axis (or draw an L line)

    Hope it helps a little and was not too much confusing...

    这篇关于在圆形雷达数学方法上表示点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆