I am trying to draw ellipse on the client side using openlayers with some mathematical functions from drawing ellipse with svg. I have achieved drawing it but not rotation what I have written for parameter and I am not sure about axis length too.
When I measure semi-major or semi-minor axis length, I am not getting the true length what I have given for 4.8 * 1000 meter.
I know PostGIS 2.1 has ST_MakeEllipse function for this but I want it on the client side.
I am sharing javascript code, reference image and result image with you. Any help would be appreciated.
Reference Image:

Codes:
var radiusX= 4,8 * 2 // Semi-major axis length - km
var radiusY= 2,5 * 2 // Semi-minor axis length -km
var rot = 125 //Rotation
var xCent = 14.7495;
var yCent = 47.4640;
var z = [];
var list = [];
for (var i = 0 * Math.PI; i < 2 * Math.PI; i += 0.01 ) {
xPos = xCent - (radiusX* Math.sin(i)) * Math.sin(rot * Math.PI) + (radiusY* Math.cos(i)) * Math.cos(rot * Math.PI);
yPos = yCent + (radiusY* Math.cos(i)) * Math.sin(rot * Math.PI) + (radiusX* Math.sin(i)) * Math.cos(rot * Math.PI);
if(i == 0 ) {
z.push( new OpenLayers.Geometry.Point(xPos, yPos).transform(map.displayProjection, map.projection));
} else {
list.push(new OpenLayers.Geometry.Point(xPos, yPos).transform(map.displayProjection, map.projection));
}
};
var linear_ring = new OpenLayers.Geometry.LinearRing(list);
var polygonFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([linear_ring]), null, null);
vector.addFeatures([polygonFeature ])
Result:

