### Author Topic: How to calculate the major and minor axes of an ellipse shape?  (Read 4179 times)

0 Members and 1 Guest are viewing this topic.

#### nashwaan

• Full Member
•   • Posts: 85 ##### How to calculate the major and minor axes of an ellipse shape?
« on: May 23, 2012, 06:07:23 AM »
Equation of the ellipse can be written as:  (x - x0)2 / a2 + (y - y0)2 / b2 = 1
where (x0, y0) is the center of the ellipse, a is semi-major and b is semi-minor.

In Visio ShapeSheet, you can define an ellipse by defining:
• The center position of the ellipse (cell X and cell Y)
• Any two points on the ellipse perimeter (one point: cell A and cell B, other point: cell C and cell D).
According to this definition, the two points on the ellipse are not restricted to be on the major and minor axis of the ellipse and they must not be perpendicular to each other. However, mathematically, there can exist an infinite number of ellipses that can have same center and same two points (see gray ellipses in the below image). But Visio draws a specific ellipse that matches these conditions (The black ellipse in the below image)! Whats the explanation? My question:
What's the mathematical equation that defines an ellipse with a center and two points on the perimeter?
Or: In ShapeSheet, how to get the major and minor axes (and the inclination angle of the ellipse) from the points defined in the Ellipse row, namely: Cells X, Y, A, B, C, and D?

Side note: To quickly test an ellipse, create a new ellispe shape and add 3 rows in the Controls section. Then insert the following formulas:
Controls.Row_1.X = SETATREF(Geometry1.X1)       Controls.Row_1.Y = SETATREF(Geometry1.Y1)
Controls.Row_2.X = SETATREF(Geometry1.A1)       Controls.Row_2.Y = SETATREF(Geometry1.B1)
Controls.Row_3.X = SETATREF(Geometry1.C1)       Controls.Row_3.Y = SETATREF(Geometry1.D1)
If you move the controls, the ellipse will change. Now, if you select the Pencil tool, you can also change the ellipse but this time Visio shows the control points on the major and minor axis of the ellipse (and will reset the control points to these positions).

Thanks,
Yousuf.
« Last Edit: May 27, 2012, 12:22:32 PM by Paul Herber »
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

#### JohnVisioMVP

• Newbie
• • Posts: 4 ##### Re: How to calculate the major and minor axes of an ellipse shape?
« Reply #1 on: June 12, 2020, 02:04:39 PM »
It appears that the points A,B and C,D are end points of the major axis and the minor axis.

John...

#### vojo

• Hero Member
•     • Posts: 1517 ##### Re: How to calculate the major and minor axes of an ellipse shape?
« Reply #2 on: June 12, 2020, 06:23:59 PM »
in general, cells A,B tend to be on the long arc of the ellipsis   while C,D are on the short arc.
Usually, these are 90 degrees apart for best results  (if points close together, then to satisfy ellipsis, it become real big)

You can also do this parametrically as well
user.angle  for where you want the points on the arc
user.major  for major axis  for length of major axis
user.minor  for minor axis for length of fminor axis

x = width*0     // otherswise have to add width terms into a and c to offset the point for from x and y non zero
y = height*0   // same for b and d
a = user.major*cos(user.angle)*0.5                      //0.5 since its from center to ellipsis edge
b = user.major*sin(user.angle)*0.5
c = user.minor*cos(user.angle + 90 deg)*0.5
d= user.minor*sin(user.angle + 90 deg)* 0.5

Elliptical arcs have a real complexity factor
A, B are very similar to ellipsis A,B....midploint on the arc
so have start angle, end angle of the arc....best to find the middle....start = 0 deg end = 120 deg....so middle is 60 deg
C takes care of rotation
D is the tough on...strictly speaking its the eccentricity of the elliptical arc...practically, use  user.minor/user.major

Tricks
- for isometric, height or minor axis = width or major axis * 0.5771   // tan of 30 deg
- isometric for elliptical arc ==>  D = sqrt(3)
- if you plan to draw a shape right up against these
- use elliptical arcs....2 to form ellipsis if need be
- on the other shape, add elliptical arc and use the loctoloc construct to reference elliptica arc to other shape.
e,g,   something like   loctoloc(pnt(<e arc.a, e arc.b>), <width of e arc>, <width of other shape>)
otherwise, if the width and height of other shape != elliptical arc shape, they wont match up

Not a lot of doc out there...so should play around with this approach to better understand behavior

#### Visio Guy

• Hero Member
•     • • Posts: 1718
• Smart Graphics for Visual People...n' Stuff ##### Re: How to calculate the major and minor axes of an ellipse shape?
« Reply #3 on: June 14, 2020, 03:09:05 PM »
For EllipticalArcTo, E and D are an angle and an eccentricity, which should completely specify the particular elliptical curve.

For the Ellipse cells, A, B and C, D are on the major and minor axes IF you use the pencil tool to move the vertices around.

If you use the ShapeSheet to set arbitrary values, then Visio must be picking something, and I don't know if you can determine it or not. In the illo below, I added a geometry section that points from the center to the A,B and C,D points. These are most certainly not on the major/minor axes. But why did Visio pick that ellipse?

If you're better at ellipse math than I am, use this technique to try and figure out what's going on - it's a lot easier to see what's happening when you add this auxiliary geometry.

« Last Edit: June 14, 2020, 03:11:04 PM by Visio Guy »
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010