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

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!

3 Comments

So you are starting with a 2x2 matrix, where the columns represent the endpoints of the principal axes of an ellipse. And you are given an arbitrary angle (e.g., from the x-axis). And you want the coordinates of the point where a line at that angle intersects the ellipse?
I guess another way of asking the question is: Given only the 2 endpoints of the vectors corresponding to the principal axis of an ellipse, can I generate an exact equation for that ellipse in order to calculate specific values on that ellipse?

Sign in to comment.

 Accepted 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.

1 Comment

Thank you! I was able to solve the given equation for x at y=0 and obtain exactly what I was looking for. Much appreciated.

Sign in to comment.

More Answers (1)

To get started, e.g.,
>> % Original data
>> E = [1 0; 0 0.5]
E =
1.0000 0
0 0.5000
>> rot_angle = -pi/4
rot_angle =
-0.7854
>> % Create rotation
>> rotation = [cos(rot_angle) -sin(rot_angle); sin(rot_angle) cos(rot_angle)]
rotation =
0.7071 0.7071
-0.7071 0.7071
>> rotated = rotation*E
rotated =
0.7071 0.3536
-0.7071 0.3536
Now the recovery part:
>> % Recover principal axes lengths
>> v = sqrt(sum(rotated.*rotated))
v =
1.0000 0.5000
>> % Recover principal axes rotation angle
>> rot_calculated = atan2(rotated(2,1),rotated(1,1))
rot_calculated =
-0.7854
Now assume you have the following:
ang = angle from x-axis for the "line"
Then you have two equations to solve for x and y:
(x/a)^2 + (y/b)^2 = 1 % a and b are the elements of v above
and
x * tan(ang-rot_calculated) = y
So solve these two equations for x and y, then re-create the rotation matrix (from ang_calculated) and rotate x and y to give you the point coordinates.
If abs(tan(ang-rot_calculated)) > 1, then maybe work with the following equation instead:
x = cot(ang-rot_calculated) * y
I.e., plug either the x expression or the y expression into the ellipse equation and solve for the other.

5 Comments

Thank you for the response, maybe there was a confusion but the angle of the "line" that I am looking for is the amount I rotated it to begin with so
ang==rot_calculated
and therefore I end up with tan(0) and am unable to get any data.
The whole reason I rotated it in the first place was to make sure the intersection point I am interested in that was originally along the line defined by ang now lies on the x-axis.
That's why I posted a problem summary and asked for confirmation first. If that problem summary is not accurate, then please re-state your problem so we can address the real issue. Once you recover the principal axes lengths and the rotation angle, I think you have everything you need to get your answer. We simply need confirmation of what exactly this "line angle" is, I guess.
Are you saying that you actually know E up front, and all of this rotation business is something inserted by you as an attempt to solve the problem? I.e., do you just have E and a line angle and simply want to know where this line angle intersects the ellipse? If so, then just use those last two equations above.
The problem summary you gave was correct and that is what I am looking for. I am confused by your solution in that you are stating there is a difference in the initial rotation angle and then the recovered rotation angle. In my problem, these will always be the same i.e.
rot_angle=ang
thus
rot_calculated=ang
and then
tan(ang-rot_calculated)=0
I only used pi/4 as an example of the graphics that I displayed.
So you have "rotated", and you are simply trying to find the intersection of that "rotated" ellipse and the x-axis?
Yes my known values are the angle I am interested in (ang) and the original matrix. I then rotated the original matrix by ang to get rotated. Now I want to find where the rotated ellipse crosses the x axis.

Sign in to comment.

Categories

Find more on Interpolation in Help Center and File Exchange

Asked:

JL
on 3 Apr 2015

Commented:

JL
on 3 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!