通过中心点,半径和角度
/ * *
*功能:objarc
*创建一个弧(与N段线)
*
*参数:
*中心-中心点
半径-圆弧半径
*α-起始角度(Grad
*ω-结束角(Grad
*段-绘制圆弧的段数
*标志-真正的:创建弧功能,从中心开始到端点到中心
*错误:创建弧功能从开始到终点
*
*返回:一个具有四个功能的数组,如果标志
*电弧特征(来自Linestring)
*起点(点)
*端点(从点)
*弦(LineString)
* /
function objArc(center, radius, alpha, omega, segments, flag)
{
var pointList=[];
if(flag)
pointList.push(new OpenLayers.Geometry.Point(center.x, center.y));
var dAngle= segments+1;
for(var i=0;i<dAngle;i++)
{
var Angle = alpha - (alpha-omega)*i/(dAngle-1);
var x = center.x + radius*Math.cos(Angle*Math.PI/180);
var y = center.y + radius*Math.sin(Angle*Math.PI/180);
var point = new OpenLayers.Geometry.Point(x, y);
pointList.push(point);
}
if(flag)
pointList.push(new OpenLayers.Geometry.Point(center.x, center.y));
var ftArc = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(pointList));
if(flag)
{
var ftArcPt0 = new OpenLayers.Feature.Vector(pointList[1]);
var ftArcPt1 = new OpenLayers.Feature.Vector(pointList[pointList.length-2]);
var ftArcSehne = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([pointList[1], pointList[pointList.length-2]]));
var arrArc = [ftArc, ftArcPt0, ftArcPt1, ftArcSehne];
}
else
var arrArc = [ftArc];
return(arrArc);
}