Generate a Rotatable Ellipse
jjweimer
Here is the basic Ellipse code I have developed, where yw and xw are waves of 361 points.
Function Ellipsoid(xo,yo,a,b,alpha)
variable xo,yo,a,b,alpha
// wave yw Assume these two waves exist .....
// wave xw
variable sinbeta = sin(-alpha*Pi/180), cosbeta=cos(-alpha*Pi/180)
xw = xo + a*cos(p*Pi/180)*cosbeta - b*sin(p*Pi/180)*sinbeta
yw = yo + a*cos(p*Pi/180)*sinbeta + b*sin(p*Pi/180)*cosbeta
return (0)
end
variable xo,yo,a,b,alpha
// wave yw Assume these two waves exist .....
// wave xw
variable sinbeta = sin(-alpha*Pi/180), cosbeta=cos(-alpha*Pi/180)
xw = xo + a*cos(p*Pi/180)*cosbeta - b*sin(p*Pi/180)*sinbeta
yw = yo + a*cos(p*Pi/180)*sinbeta + b*sin(p*Pi/180)*cosbeta
return (0)
end
A plot of yw versus xw shows the ellipse.
I should also mention, the ellipse is to be drawn on linear or log-log coordinates. One intent is to show how an elliptical region spanning multiple decades in scale in linear coordinates takes on a completely different shape when displayed in log-log coordinates. Anyone who is familiar with materials selection charts that are popular in books by M. Ashby and others will see the immediate pedagogical utility of my efforts.
I have attached an experiment to illustrate where I am so far.
Can anyone suggest a better way to do what I need?
http://www.mathhelpforum.com/math-help/pre-calculus/31004-rotated-ellip…
You should probably recentre the ellipse onto the origin first though, and put it back once you're finished.
March 25, 2010 at 08:11 pm - Permalink
I'll just leave rotation off for now.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
March 26, 2010 at 03:24 pm - Permalink
Rotation is a unitary operation, therefore keeping the distances between points constant - that's why your ellipse, if your code is correct, cannot skew. In fact, your code is OK, and your ellipse does NOT skew, this happens only because of different scales on the x- and y-axis. If you fix the scales to be the same, you will see that your function works as expected.
Cheers,
gregor
March 28, 2010 at 08:18 am - Permalink
Oh! Duh! Of course. My mistake was certainly in forgetting that my axes were not isomorphic in scale. Rotation therefore works as expected. The code snippet is found here.
Thank you!
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
March 29, 2010 at 10:38 am - Permalink
That will add a submenu to your Graph menu. It provides an interactive way to draw an ellipse with draggable handles to change the aspect ratio and angle.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 2, 2010 at 10:22 am - Permalink
I will look into it. My direct interest is to draw an ellipse of a given aspect/angle a) in normal coordinates and then transform to log-log to see the distortion in shape and b) in log-log coordinates and then transform to normal coordinates to see the distortion in shape. This is all related to illustrating the basics of so-called "materials selection charts" where ellipses are used on log-log plots to map out inclusive regions for two coordinating properties (strength vs density for example) of certain classes of materials (metals, composites ....). Showing that a pure ellipse in one coordinate framework is not a pure ellipse in another is a fundamental part of understanding such charts.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
March 31, 2010 at 09:05 am - Permalink
Woops. My package doesn't handle log axes...
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 2, 2010 at 10:25 am - Permalink