Formulas for ellipse at an angle, in Excel.

AI Thread Summary
The discussion focuses on how to create and manipulate ellipses in Excel, particularly regarding rotation. The general formula for an ellipse is acknowledged, but participants emphasize using parametric equations for easier implementation in Excel. To rotate the ellipse, a rotation matrix is suggested, and participants discuss how to adjust the formulas to achieve this. There is also a focus on ensuring that the graph's axes remain consistent to accurately reflect the rotation. The conversation concludes with insights on using these formulas for practical applications, such as modeling bow limbs in archery.
Thorvald
Messages
32
Reaction score
0
Hi.

I know about the general formula for an ellipse: x^2/a^2 + y^2/b^2 = 1, that can be used to isolate y and calculate x,y points in excel. That's great, so far so good. That will create a ellipse, with horizontal A (x) axis and vertical B (y) axis. But what if one wants to rotate the ellipse some amount of degrees, like 20 degrees, 60 degrees - in Excel?? Is there a simple way to do that in Excel - or to apply that to the general formula for the ellipse? Maybe I am thinking too complicated, so that I can't see the solution... :smile:
 
Engineering news on Phys.org
Take your result and x and y values, and run them through a simple rotation matrix. In 2D is should be fairly straightforward.
http://en.wikipedia.org/wiki/Rotation_matrix

Might be a difficult way to get it in closed form within your ellipse function, but as a two-step process, should be pretty easy.
 
Thorvald said:
I know about the general formula for an ellipse: x^2/a^2 + y^2/b^2 = 1
That is not the general formula for an ellipse. A general formula would describe all ellipses. The given expression is a canonical form, not a general form.

For plotting some curve it is often easier to use a parametric description of the curve. One parametric description of that canonical ellipse is

\begin{align*}<br /> x &amp;= b\cos t \\<br /> y &amp;= a \sin t<br /> \end{align*}<br />

This parametric description is very easy to implement in Excel. Let column A be used for t, column B for x, and column C for y. Make column A, the t values, march from 0 to 2*pi in uniform steps. Columns B and C are the simple expressions b*cos(t) and a*sin(t), where t is the column A value for the row in question.

Suppose instead these x and y values are for some axes rotated with respect to the x and y axes. Label columns B and C u and v instead of x and y. Add two more columns to denote x and y. The x value is u*cos(theta)-v*sin(theta) while y is u*sin(theta)+v*cos(theta), where theta is some defined value (just as are a and b).
 
Hmmm., thanks for your replies - very useful. I have used this formula to calculate points (or at least the 1/4th of the ellipse) in excel: y = sqrt(b^2*(1-x^2/a^2), where I choose values for a and b. Does your formula y = b cos(t), give the same result (possibly giving the whole ellipse)? And t is angles from 0 to 360 degrees?? That formula for y is of course easier, but my first formula is now programmed in Excel and works - so maybe I just keep it.

Then to rotate it, it seems like you both agree that the new formula for y would be:

y' = x sin(t) + y cos(t)

This I could simply add in a column after my present x, y columns, to achieve the same ellipse, just rotated t degrees - (I think). Is that a correct understanding of it? Must try it out when I get some time... :)
 
Does this look correct? It does not look like the curve have been rotated 45 degrees?

I may want to use the formulas for creating the whole ellipse and then just take out what part of the ellipse, I want to use. But this was just for now to see if it works.

Ellipsecalculation.jpg
 
It looks OK, but just to check, it might help to define your rotation angle as 90°. So, you're point at (0,145) should go to (-145,0). Do each step separately just to make sure everything is cool.
 
You're right - it looks ok. I know why it didn't look exactly correct - because as values changes the axes in the graph changes... Is it possible to automatically control the graph grid, so it is the same in the different pictures?

Ellipsecalculationtest1.jpg


Ellipsecalculationtest2.jpg


Ellipsecalculationtest3.jpg
 
Hmmm., wait - when I rotate the ellipse 90 degrees, I would expect that it would "stand up". I.e. the long part of ellipse, being vertical. Why that is not the case?
 
Aaaah - wait again - it may be the case, it's just the grid/axes that teases me...
 
  • #10
D H said:
...that canonical ellipse is

\begin{align*}<br /> x &amp;= b\cos t \\<br /> y &amp;= a \sin t<br /> \end{align*}<br />

It looks like you have made a mistake here. I couldn't understand why, when I used this formula the "a" was smaller than the "b" - but it's logic, because a is the biggest value along the x-axis, so "a" should be in the formula for x.
 
Last edited:
  • #11
How to rotate the ellipse in the point (0,-b)?? The formulas you have given, rotates it around (0,0). I'd like to move the ellipse (shouldn't be difficult), use part of the ellipse (not difficult, either) and then rotate it at what was originally (0,-b).
 
  • #12
Thorvald said:
How to rotate the ellipse in the point (0,-b)?? The formulas you have given, rotates it around (0,0). I'd like to move the ellipse (shouldn't be difficult), use part of the ellipse (not difficult, either) and then rotate it at what was originally (0,-b).
(1) First figure out where the origin rotates to, if you rotate by an angle θ about the point (0,-b). Maybe the easiest way to do this is to rotate the point (0,-b) about the origin by θ, figure out it's displacement, and realize that the origin will by displaced that amount in the opposite direction when rotated by θ about (0,-b)

(2) Next rotate the ellipse by θ about the origin, just as before.

(3) Finally, apply the displacement that you determined in step (1) to the entire ellipse.

By the way, if you parameterize the initial (unrotated) ellipse as was suggested before:
x = a cos(t) (yes, you're correct, a goes with x)
y = [STRIKE] b cos(t) [/STRIKE] EDIT -- oops, that should be: b sin(t)​
Then I think you're ellipse could look a lot nicer, especially near the vertices. Just be aware that Excel assumes radians when doing trig functions, so:
0 ≤ t ≤ 2*pi​

Also, you might want to set your axis scales to fixed values, so that you are not dealing the the autoscaling issues whenever you move the ellipse.

Final piece of advice: I like to give Excel graphs a white background. Whenever I see a gray background on an Excel graph, it says to me "I'm a total noob! Or I'm too lazy to bother adjusting Excel's built-in defaults."

Anyway, good luck. :smile:
 
Last edited:
  • #13
You are right about the white background in graphs. I normally do that too (but haven't doen it yet in this one... :-) ) - Well, done it now...

Yes, I am now using the cos/sin-formulas for the ellipse - hey, did you write wrong again? Shouldn't you use sin for y?? Or is it cos for both x and y?

I use degrees rather than radians, as I don't "understand" radians. So I just write in Excel for cos(t): COS(t*PI()/180), t given in degrees.

To do what I wanted, I used the following approach:
First I made a set of x,y columns, creating just the ellipse and nothing else. Then I made a column called degrees and a new set of columns called x' and y' - and here calculated the rotated ellipse. In the x,y columns, I could then find the (0,-b) and compare with the values in x',y' columns. Then I could create a formula for how much x',y' was moved compared to x,y, plus I knew where I wanted the "0,-b" point to be located - and made that in a new set of columns x'',y''.

This ellipse approach is a add-on to another Excel program. This program can be used to study different limb profiles for bows (archery), how they will bend etc. up to a full drawn bow. The ellipse add-on was an idea I got, to have a way to automatically calculate a mathematical correct geometrical curve for the bow-limb. The ellipse add-on can be used to make about anything from straight limbs over slightly curved limb to curled recurve bow limbs. See also attached to get an idea of how I use it.

If you see something that doesn't look correct in how I rotate and move the ellipse etc., just tell me.
 

Attachments

Back
Top