用圆形雷达数学方法表示点 [英] Representing Points on a Circular Radar Math approach
问题描述
我正在编写一个简单的应用程序,可以告诉你周围的朋友,但不是在普通地图上,而是在像UI这样的真正的圆形雷达上:
< img src =https://i.stack.imgur.com/9b8CL.pngalt =[Imgur]>(是构建4x4变换矩阵的数学基础。 将所有点转换为RADAR坐标系 只需乘以 RADAR 变换矩阵 所以点 现在只需将所有坐标乘以< RADAR scale 希望它有一点帮助,并且不要太混乱...... 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? 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 If you want more precision handle Earth as ellipsoid instead of sphere create RADAR local cartesian coordinate system Basically you need to obtain 3D vectors for 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.
convert all points to RADAR coordinate system just multiply all points by RADAR transform matrix so the points so now just multiply all cordinates by RADAR scale
after this just draw the dot to RADAR (swap Hope it helps a little and was not too much confusing... 这篇关于用圆形雷达数学方法表示点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
M
Q(i)= P(i)* M
Q(i)
现在是本地的到雷达
(0,0,0)
指雷达来源(中心)
(1,0,0)
点数t
(0,1,0)
指向东
(0,0,1)
加分
scale = RADAR_radius / RADAR_range;
RADAR_radius
是您在屏幕上的大小雷达,以像素或坐标单位为单位
RADAR_range
在这之后, RADAR 最大圆代表[m]
/ b> strong>(交换 x,y
因为我使用 X
作为北不 Y
),你也可以放弃所有距离较远的点。您还可以通过在垂直轴上添加 Z
坐标(或绘制L线),像旧Elite一样添加3D RADAR
$ b
(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 NorthXY
plane is equatorlong = < 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)
X,Y,Z
axises. They must be perpendicular to each other and pointing to the right direction from RADAR origin point (P0)
.//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
M
Q(i) = P(i)*M
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 upscale = RADAR_radius/RADAR_range;
RADAR_radius
is size of you RADAR on screen in pixels or units of coordinatesRADAR_range
is the max distance the RADAR biggest circle represents [m]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)