Like the picture show blow, i have two coordinates, and i want to draw an ellipse which the major axis edges match these two point.
I have tried get the mid point between these two coordinates and draw an ellipse base on these one coordinate. The code like these, below function return the array of ellipse points which is just i want:
function add_oval(centre, x, y) {
var assemble = new Array();
var angle;
var dot;
var tangent = x / y;
for (i = 0; i < 36; i++) {
angle = (2 * Math.PI / 36) * i;
dot = [centre.lng + Math.sin(angle) * y * tangent, centre.lat + Math.cos(angle) * y];
assemble.push(dot);
}
return assemble;
}
But the problem is, these can only draw a horizontal ellipse, i don't know how to change the angle.
Does someone know how to solve my problem?