Like hitting the picture, I have two coordinates, and I want to draw an ellipse that matches the edges of the main axes.

I tried to get the midpoint between these two coordinates and draw the base of the ellipse on that one coordinate. Code like this below the function returns an array of ellipse points that I just 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 that they can only draw a horizontal ellipse, I don’t know how to change the angle.
Does anyone know how to solve my problem?
source
share