## Sketcher: Ellipse support

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

### Re: Sketcher: Ellipse support

Hi! Sorry, I couldn't read the whole thread, but I want to emphasize the importance of ellipse focuses. I can't think of any functional application of ellipse that does not involve its focuses.
BTW. With focuses in mind, it makes sense to have strict major axis.
EDIT: well, I've just found a practical application without focuses. Anyway...
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

### Re: Sketcher: Ellipse support

applications of ellipse:
ellipsoidal reflector, for focusing of light/radio/sound/whatever from a nearby point source. Parabolas and (less so) hyperbolas are useful in this respect too.
elliptical aperture. If one has a parallel beam of light incident to a plate at an angle, and one wants to get a circular illuminated spot, one might want to make an elliptical shaped aperture and place it normal to the beam.
elliptical gears. Uncommon stuff...
domes. Although a сatenary shape is probably more applicable in this case.
UFO
DevJohan
Posts: 41
Joined: Sun Jul 13, 2014 2:36 pm
Location: Stockholm, Sweden

### Re: Sketcher: Ellipse support

DeepSOIC,
It's a common misconception aliens use ellipses, they really use non-rational UFOCurves for their UFOs and that's why they fly.
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Ellipse support

think you mean with reference specifically to ellipses? because it already works with the edges of other elements.
Sure. Specifically to ellipses.
1) if the neither Ellipse nor the line is constrained and I use point on line constraint with the end of the line and the edge of the Ellipse and then it moves the ellipse to meet the constraint requirements...this works but surprised me as I expected the line would be the element that would move.
Both partial derivatives are equal in value, the solver has the freedom to modify one or the other or both. If you lock the ellipse then it moves the line (but it could increase the major/minor axis of the ellipse to meet the line)... or both.
I can get a bug, if I try to place a line on the major and minor axes and I place the line somewhere close top what I want it works....to align them correctly I had to cheat by adding a directional length constraint of twice the major diameter to the line on the major axis and a perpendicular constraint on the two line so the other aligns with the minor axis. When phi can be set relative to a line rather than just x axis, then phi constraint would be the solution to use here.
Well this is not a bug IMHO, I guess you me twice the major semidiameter or twice the major radius... There are infinite solutions from both ends point on curve with or without going through the center point of the ellipse...

you could actually make a line at an angle with respect to X equal to the phi of the ellipse (set via constraint) and then make it pass thru center and then both extremes point on ellipse...
Now if I do the above but start with a line off to the right (relative x positive direction) and do a point on line constraint wit hthe closest end of the line it works as expected but if I then add the centre point of the Ellipse to the line with point on line constraint then it algins the line correctli but does not flip it into the correct direction
This is not a problem of ellipse implementation. Try to do the same with a circunference and you will have the same problem: it does not flip. It might be an issue of the point on line constraint implementation.
then I tried applying another point on line constraint to the other end of the line (end point) and the ellipse ...it still did not flip, it just gave me a conflicting constraints error and while in edit mode the line just disappeared, a view fit all did not show it.
This is interesting and is worth reporting it. If you can generate this situation systematically please file a mantis ticket (specially if with a circle the same happens)...
This is an example of what I was trying to achieve in the last post, if you create all the elements close to where they are supposed to be it did work.
Line not flipping is a problem of the line on point constraint. When thinking of the point on ellipse curve, you should think that the system is going to snap the point at the point of the ellipse that is closest to it. This might help...

Now that you managed to do it, you can remove any phi constraint and try to apply an angle to the ellipse by applying a normal angle constraint between the line on the major axis and the X axis (or another line)...
Hi! Sorry, I couldn't read the whole thread, but I want to emphasize the importance of ellipse focuses.
I do not blame you. It is too long To me it makes sense, but as a generic functionality that would generate desirable construction lines and points of a geometry constrained to the actual geometry... for those who had technical drawing in high school: Do you know a graphical way of obtaining the focuses of an ellipse, given the ellipse and its center?
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Ellipse support

Now the line (construction line) on the major axis is constraining the ellipse at 45º from the major axis.
Ellipse11.png (29.75 KiB) Viewed 1390 times
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Ellipse support

And now it is 45 degrees from the line that is at 20 degrees from the X axis...
Ellipse12.png (30.32 KiB) Viewed 1390 times
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

### Re: Sketcher: Ellipse support

Code: Select all

``Do you know a graphical way of obtaining the focuses of an ellipse, given the ellipse and its center?``
I don't(EDIT: I feel like I just invented one... at least, I'm sure it is possible). But, the reverse is easy. Given the two focuses, it is easy to get both axes and sizes of the ellipse with just a little bit of construction geometry: major axis is the line that goes through focuses; center is in the middle between focuses (symmetry constraint), minor axis is perpendicular; once axes are here the intersections can be used for size.

Though simple, it will likely be inconvenient to make that much geometry to just define the size, so an ellipse-specific constraint is important.

Thinking free, I envision this like:
* the ellipse on screen is just the ellipse curve and two points - its focuses. (a center point would be good to have as well)
I don't like the concept of phi that I've seen on some sreenshots. I'd prefer to apply angle constraint to major axis. If you expose the focuses, I thing no extra work is needed for angle constraint to work + you get vertical/horizontal/parallel/perpendicular constrains for free!
Looks like I'm a bit late on this . Feel free to come as you go.
Last edited by DeepSOIC on Thu Sep 11, 2014 1:09 pm, edited 1 time in total.
jmaustpc
Posts: 9619
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

### Re: Sketcher: Ellipse support

Hi Abdullah
I did not realise the flip issue was general...I will test and report as you said.

I have an example that thinks it has redundant constraint when I don't think it does...here is a screen shot....
• the ellipse is fully constrained
• then I added the line with a coincident constraint on the centre of Ellipse with the line starting point
• the end point of the line then is constrained the edge of ellipse with point on line constraint
so far so good...now if you put a vertical constraint on the line the sketcher reports a redundant constraint error
ellipse_line_redundant.jpg (18.34 KiB) Viewed 1377 times

redundantconstraintonlinewithellipse.fcstd
here is a screen shot with the vertical constraint.
ellipse_line_redundant1.jpg (72.41 KiB) Viewed 1377 times

Jim
jmaustpc
Posts: 9619
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

### Re: Sketcher: Ellipse support

DevJohan wrote:DeepSOIC,
It's a common misconception aliens use ellipses, they really use non-rational UFOCurves for their UFOs and that's why they fly.

everyone knows that aliens use non-rational bezier curves in their space ships....so that no one will believe in them.
abdullah
Posts: 3174
Joined: Sun May 04, 2014 3:16 pm

### Re: Sketcher: Ellipse support

I have an example that thinks it has redundant constraint when I don't think it does...here is a screen shot....

the ellipse is fully constrained
then I added the line with a coincident constraint on the centre of Ellipse with the line starting point
the end point of the line then is constrained the edge of ellipse with point on line constraint

so far so good...now if you put a vertical constraint on the line the sketcher reports a redundant constraint error
I am sorry, but I am not able to replicate the problem. If I download your sketch and open it, it says 1 degrees of freedom (you can grab the point on ellipse curve and move it around).

Now I select the two points of the line and click the 90-degrees-rotated-H-shaped icon (which I believe is what you refers as vertical constraint). As far as I give a value not higher than the minor radius it works ok for me... could you just open the file and try?
Ellipse13.png (67.51 KiB) Viewed 1370 times