Perimeter of a part of an ellipse
5 views (last 30 days)
Show older comments
SIBANANDA PANIGRAHY
on 6 Jun 2016
Edited: Roger Stafford
on 9 Jun 2016
I know the ellipse(center of ellipse,length of semi-axes,orientation).I also know the co-ordinates of two points which comprise the end points of the curve which is a part of the given ellipse.How can I find out the perimeter of this part of an ellipse??
1 Comment
Torsten
on 6 Jun 2016
You know how to compute the arc length of a curve in parametric form ?
Best wishes
Torsten.
Accepted Answer
John BG
on 7 Jun 2016
Edited: John BG
on 7 Jun 2016
Sibananda
If you already have a and b, then you don't really need the ellipse centre point, or the ellipse tilt angle.
The points of the ellipse have a unique angle, let's say the pair of points you want to measure the section of perimeter in between are
p1: angle1
p2: angle2
then the length you are after
L=perim_ellipse(angle1,a,b)-perim_ellipse(angle2,a,b)
where perim_ellipse is a function that calculates the perimeter length from 0 to angle.
If you really know it's an ellipse, or what's the same: you can afford neglecting the approximation error then you don't really need the parametric representation of the ellipse and you may <http://mathworld.wolfram.com/Ellipse.html>
Perimeter=a*E(t,sqrt(1-b^2/a^2))
should coincide with
b*E(t,sqrt(1-a^2/b^2))
where E(t,k) is an elliptic integral
for instance
a=1
b=2
k1=sqrt(1-b^2/a^2)
fun1=@(angle) sqrt(1-k1^2*(sin(angle)).^2)
E1=integral(fun1,0,2*pi)
E1 =
9.688448220547675
k2=sqrt(1-a^2/b^2)
fun2=@(angle) sqrt(1-k2^2*(sin(angle)).^2)
E2=integral(fun2,0,2*pi)
E2 =
4.844224110273838
and
E1/E2
=
2
2.- go straight to the S.Ramanujan 2nd approximation:
a=1;b=2; % for instance
h=(a-b)^2/(a+b)^2
h =
0.111111111111111
Perimeter=pi*(a+b)*(1+3*h/(10+(4-3*h)))
Perimeter =
9.654650593958877
E1-Perimeter
=
0.033797626588798
more approximations here:
http://www.numericana.com/answer/ellipse.htm#elliptic http://www.johndcook.com/blog/2013/05/05/ramanujan-circumference-ellipse/ http://paulbourke.net/geometry/ellipsecirc/
2.- if you actually have the points, then is when the parametric formulation of the ellipse can be integrated,
Centring and removing tilt the parametric equations of an ellipse with axes a and be are:
t=[0:.01:2*pi]
x=a*cos(t)
y=b*sin(t)
L=[x;y];
perimeter=0;
for k=2:1:length(t)
perimeter=perimeter+dist1(L(:,k-1),L(:,k));
end
perimeter =
9.682037252420420
So,
function L1=perim_ellipse(t1,a,b)
% t1 angle in radian of ellipse point
% a,b: ellipse absolute minor and major axes, without tilt, in any order
t=[0:.01:t1];
x=a*cos(t);
y=b*sin(t);
ellipse_points=[x;y];
L1=0;
for k=2:1:length(t)
L1=L1+dist1(ellipse_points(:,k-1),ellipse_points(:,k));
end
end
checking
format long;
L0=perim_ellipse(2*pi,1,2);
L0 =
9.682037252420420
So, to calculate the arc length you asked, of let's say angle1=45º and angle2=135º:
angle1=pi/4;
angle2=3*pi/4;
a=1;b=2;
L12=abs(perim_ellipse(angle1,a,b)-perim_ellipse(angle2,a,b))
L12 =
1.930084466978536
If you find this answer of any help solving your question,
please click on the thumbs-up vote link, or mark this answer as accepted
thanks in advance
John
2 Comments
More Answers (1)
Roger Stafford
on 6 Jun 2016
Edited: Roger Stafford
on 6 Jun 2016
If (x0,y0) is the center of the ellipse, if a and b are the two semi-axis lengths, and if p is the counterclockwise angle of the a-semi-axis orientation with respect the the x-axis, then the entire ellipse can be represented parametrically by the equations
x = x0 + a*cos(p)*cos(t) - b*sin(p)*sin(t)
y = y0 + a*sin(p)*cos(t) + b*cos(p)*sin(t)
where t is a parameter varying from -pi to +pi. If (x1,y1) and (x2,y2) are the two endpoints of the elliptical arc in question in such a way that the desired arc goes counterclockwise from (x1,y1) to (x2,y2), then the corresponding endpoint parameters t1 and t2 can be solved for as follows:
A = [a*cos(p),-b*sin(p);a*sin(p),b*cos(p)];
T1 = A\[x1-x0;y1-y0]; % Solve for cos(t1) and sin(t1)
t1 = atan2(T1(2),T1(1)); % Determine t1
T2 = A\[x2-x0;y2-y0]; % Solve for cos(t2) and sin(t2)
t2 = atan2(T2(2),T2(1)); % Determine t2
if t2 < t1, t2 = t2 + 2*pi; end % Ensure that t2 >= t1
t = linspace(t1,t2); % Make t start at t1 and end at t2
x = x0 + a*cos(p)*cos(t) - b*sin(p)*sin(t);
y = y0 + a*sin(p)*cos(t) + b*cos(p)*sin(t);
The x and y vectors will trace the desired elliptical arc. To verify this with a plot, you can do this:
tt = linspace(-pi,pi);
xx = x0 + a*cos(p)*cos(tt) - b*sin(p)*sin(tt);
yy = y0 + a*sin(p)*cos(tt) + b*cos(p)*sin(tt);
plot(xx,yy,'c:',x0,y0,'w*',x,y,'y-',x1,y1,'ro',x2,y2,'go')
axis equal
The desired arc is in yellow, the remainder of the ellipse is in dotted cyan, the point (x1,y1) is red, (x2,y2) is green, and the center of the ellipse is a white asterisk.
1 Comment
Roger Stafford
on 9 Jun 2016
Edited: Roger Stafford
on 9 Jun 2016
Where you said ‘perimeter’, Sibananda, it now seems apparent that you meant perimeter arclength for the elliptical curve segment between the two points. If that is the case, this arclength can be found, as Torsten indicated, taking the integral with respect to the parameter t of the expression "sqrt((dx/dt)^2+(dy/dt)^2)" from the t1 to the t2 determined above. In this case this expression will be equal to
sqrt(a^2*sin(t)^2+b^2*cos(t)^2)
and thus the desired arclength would be:
s = integral(@(t) sqrt(a^2*sin(t).^2+b^2*cos(t).^2),t1,t2); % Corrected
(This integral can be also be evaluated in terms of elliptic integrals of the second kind, incomplete.)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!