OpenLayers Simple Vector Animation, Thaleskreis and
how to draw an arc (by centerpoint, radius, start- and endangle)

show animation draw arc

Animation, Winkel
Drawing Params
start angle
end angle
show chord
Description[x]

Both cases are simply the calculation of points on a circle. The only difference is that for the animation the points are not used to draw the arc.

Calculation of points on a circle
(by centerpoint, radius and angle)

var x = center.x + radius * Math.cos(angle * Math.PI/180);
var y = center.y + radius * Math.sin(angle * Math.PI/180);
Function to create an arc feature
(by centerpoint, radius and angle)
/**
 * Function: objArc
 * creates an arc (a linestring with n segments)
 *
 * Parameters:
 * center   - center point
 * radius   - radius of the arc
 * alpha    - starting angle (in Grad)
 * omega    - ending angle   (in Grad)
 * segments - number of segments for drawing the arc
 * flag     - true  : create arc feature from center to start- to endpoint to center
 *            false : create arc feature from start- to endpoint
 *
 * Returns: an array with four features, if flag=true
 *          arc feature     (from Linestring)
 *          the startpoint  (from Point)
 *          the endpoint    (from Point)
 *          the chord       (from 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);
}