How can I generate a set of points evenly distributed along the perimeter of an ellipse?

后端 未结 8 716
庸人自扰
庸人自扰 2020-12-15 22:28

If I want to generate a bunch of points distributed uniformly around a circle, I can do this (python):

r = 5  #rad         


        
相关标签:
8条回答
  • 2020-12-15 22:49

    There is working MATLAB code available here. I replicate that below in case that link ever goes dead. Credits are due to the original author.

    This code assumes that the major axis is a line segment from (x1, y1) to (x2, y2) and e is the eccentricity of the ellipse.

    a = 1/2*sqrt((x2-x1)^2+(y2-y1)^2);
    b = a*sqrt(1-e^2);
    t = linspace(0,2*pi, 20);
    X = a*cos(t);
    Y = b*sin(t);
    w = atan2(y2-y1,x2-x1);
    x = (x1+x2)/2 + X*cos(w) - Y*sin(w);
    y = (y1+y2)/2 + X*sin(w) + Y*cos(w);
    plot(x,y,'o')
    axis equal
    
    0 讨论(0)
  • 2020-12-15 22:51

    Do take into consideration the formula for ellipse perimeter as under if the ellipse is squashed. (If the minor axis is three times as small as the major axis)

    tot_size = np.pi*(3*(a+b) -np.sqrt((3*a+b)*a+3*b))
    

    Ellipse Perimeter

    0 讨论(0)
提交回复
热议问题