计算屏幕外地图位置的半径

Jac*_*ack 3 math android google-maps

题:

如何考虑屏幕的矩形形状以确保圆圈精确地绘制到填充边界?

以下适用于"圆形"区域,但不适用于矩形区域......

dx = abs(center.x - place.x);
dy = abs(center.y - place.y);
dh = Math.sqrt((dx * dx) + (dy * dy));
radius = dh - padding;
Run Code Online (Sandbox Code Playgroud)

光环设计: 光环的想法

如果问题似乎不明显,下面的图像代表我正在使用的当前方法.取决于地点的位置影响它伸入屏幕空间的距离. 在此输入图像描述

dio*_*emo 5

认为这应该有效.没有测试过.

dx = abs(placeLocationPixels.x - ourLocationPixels.x)
dy = abs(placeLocationPixels.y - ourLocationPixels.y)

ox = dx - ((screenSize.x / 2) - padding);
oy = dy - ((screenSize.y / 2) - padding);

if (ox < 0) ox = 0;
if (oy < 0) oy = 0;

radius = sqrt((ox*ox) + (oy*oy));
Run Code Online (Sandbox Code Playgroud)

编辑:这不是任何特定的语言.