MATLAB: How to extract length along an angle that intercepts an ellipse.

ellipseintersectintersection pointsmatrix manipulationmatrix rotationvector projection

I am working on a problem where I obtain a strain matrix and want to extract the magnitude of that strain along a specified angle. The way I envision it is that the strain matrix represents the vectors corresponding to the major and minor axis of an ellipse and I then want to find the magnitude of a line along my specified angle that intersects that ellipse.
For example above I have a strain matrix that would be defined as
E=[ 1 0;
0 0.5];
This could be represented as the blue ellipse I plotted in the figure. In this scenario my then specified angle is 45˚ (pi/4) represented by the red line. In this scenario the magnitude I am looking for would be:
sqrt(0.45^2+0.45^2)=0.6364
Now I am trying to figure out how to do this via math. I imagine I should be able to simply rotate the ellipse by the negative of my given angle so that the point along the angle I am interested in is now along the x axis and I should be able to simply extract out the x component, as shown graphically:
So in doing this mathematically I figure I rotate the strain matrix as below:
E=[ 1 0;
0 0.5];
rotation=[cos(-pi/4) -sin(-pi/4);sin(-pi/4) cos(-pi/4)];
rotated=rotation*E;
I then end up with:
rotated=[ 0.7071 0.3536;
-0.7071 0.3536];
Which by my earlier definition of an ellipse gives the red rotated ellipse above (one axis point at 0.7071,-0.7071 and one axis at 0.3536,0.3536) which should intersect the X-axis at my desired point of x=0.6364.
So how do I extract out this value from the matrix:
rotated=[ 0.7071 0.3536;
-0.7071 0.3536];
Is there a simpler or easier way to accomplish this same task? Thank you!

Best Answer

You apparently have the center of your ellipse located at the coordinate origin. If [px,py] is the endpoint of one principal axis and [qx,qy] the other principal axis, then an equation of the ellipse is:
(px*x+py*y)^2/(px^2+py^2)^2+(qx*x+qy*y)^2/(qx^2+qy^2)^2 = 1
for points (x,y) on the ellipse.
This is rather different from your original question of finding the length of a line from the origin to a point on the ellipse if the angle of the line with respect to the x-axis is known. The way to solve this second question is first to determine the angle between the one principal axis and the given line. For that see the thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/162503
in which I give a formula for this using the 'atan2' function.
Once this angle is determined, the distance from the center to a point on the ellipse is:
d = 1/sqrt(cos(t)^2/a^2+sin(t)^2/b^2);
where t is the angle of the line to the principal axis of length a and where b is the other orthogonal principal axis length.
Related Question