根据坐标、半径和方向角,计算圆弧边缘中心顶点坐标的算法
function DegToRad(const Degrees: Extended): Extended; { Radians := Degrees * PI / 180 }
begin
Result := Degrees * (PI / 180);
end;
procedure DPtoVP(dx, dy: Double; var vX, vY: integer);
begin
// FViewArea即可视区域的范围,主要用到其坐标范围
vX := Trunc((dx - FViewArea.Left) / Scale);
if(FCoordKind = csLeftHand) then
vY := Trunc((dy - FViewArea.Top)/Scale)
else
vY := Trunc((FViewArea.Top - dy) / Scale);
end;
function GetCellCenterInfo(const AGisX: TGisX; dX, dY: Double;
const AntLength: Integer; const Azimuth: Double): TPoint;
{
获取扇形上弧线中心顶点,结果为屏幕坐标
}
const
CDOriginAngle = Pi / 2;
CD360Angle = Pi + Pi;
var
rAngle: Double;
begin
Result.X := CIInvalid;
Result.Y := CIInvalid;
if not Assigned(AGisX) then Exit;
if (dX < -180) or (dX > 180) then Exit;
if (dY < -90) or (dY > 90) then Exit;
//将经纬度转换为屏幕坐标
AGisX.ViewPort.GeoCoordSys.ConvertForword(dX, dY, dX, dY);
// 平面坐标转换成屏幕坐标
DPtoVP(dX, dY, Result.X, Result.Y);
rAngle := CDOriginAngle - DegToRad(Azimuth);
if rAngle < 0 then rAngle := rAngle + CD360Angle;
Result.x := Result.x + Trunc(AntLength * Cos(rAngle));
//由于屏幕坐标Y坐标是向下的,所以下面减法
Result.y := Result.y - Trunc(AntLength * Sin(rAngle));
end;
function GetCellCenterInfo(const dX, dY: Double;
const AntLength: Integer; const Azimuth: Double): TPoint2DX;
{
获取扇形上弧线中心顶点,结果为经纬度
}
const
CDOriginAngle = Pi / 2;
CD360Angle = Pi + Pi;
var
rAngle: Double;
begin
Result.X := CIInvalid;
Result.Y := CIInvalid;
if (dX < -180) or (dX > 180) then Exit;
if (dY < -90) or (dY > 90) then Exit;
rAngle := CDOriginAngle - DegToRad(Azimuth);
if rAngle < 0 then rAngle := rAngle + CD360Angle;
Result.x := dX + AntLength * Cos(rAngle);
Result.y := dY + AntLength * Sin(rAngle);
end;