Sketcher: Ellipse support

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Sketcher: Ellipse support

Post by abdullah »

Hi guys!

This is just to inform that I am getting busy with adding Ellipse support in the Sketcher. I am still in a very very very preliminary stage (... and I do not even know if I will be able to do it)...

I have assigned to myself Mantis tickets: 0001328 and 0001297.

Just a teaser:
Ellipse0.png
Ellipse0.png (20.02 KiB) Viewed 5122 times
There is still a looong way ahead...
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Sketcher: Ellipse support

Post by jmaustpc »

great Abdullah!

I was wondering how it works, are you thinking it would be click on first Centre then Major then minor diameter? Although I suppose it will be just diameter 1 and diameter 2 as their size as determined by the point location which will in tern define which is minor and which is major?


Jim
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Ellipse support

Post by abdullah »

I have an insertion method (with a button), with center point, vector of major axis (with modulus providing for major radius) and vector of minor axis (with modulus providing for minor radius). However, it still does not work properly (and I swiched to constraints, while I think about it), because I have to force somehow to two perpendicular axis, or the creation method (with reason) complains that they are not valid...

In the meanwhile I insert them with python as, for example:
App.ActiveDocument.Sketch.addGeometry(Part.Ellipse(App.Vector(20.000000,0,0),App.Vector(0,10.000000,0),App.Vector(10,10,0)))

Creation method has to provide somehow the angle between the X axis of the sketch and the X axis of the ellipse (via vector or other), otherwise we would not be able to have a "rotated" elipse...

... this also generates additional caveats regarding constraints:
1. New constraints? (now we have two radii)
2. New constraint for angle between elipse major axis and X axis?
...

I am still thinking about many things... when it is a little less alpha I will publish it to have some feedback.
Ellipse1.png
Ellipse1.png (53.46 KiB) Viewed 5101 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Ellipse support

Post by abdullah »

BTW, the padding works out of the box once when you have the elipses in...
Ellipse2.png
Ellipse2.png (20.42 KiB) Viewed 5097 times
mrlukeparry
Posts: 655
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Sketcher: Ellipse support

Post by mrlukeparry »

Hi abdullah,

Great work so far. Do you have this in your git repo just to have a look at?

Aren't ellipses usually defined by three points and then use distance constraints to determine major and minor axes and rotation? I guess there will be also an ellipse arc too for adding an angle constraint.

I'd be interested to see how you get the point on line constraint to work. Maybe it's simpler than I think it is and only requires tweaking the arc/circle code.

Luke
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Ellipse support

Post by abdullah »

Thanks guys!!
Do you have this in your git repo just to have a look at?
Not yet. At this stage it is still way too early. I am planning to release it when the implementation starts making sense. This would allow to debug and also get feedback from you guys.
Aren't ellipses usually defined by three points and then use distance constraints to determine major and minor axes and rotation?
Well, to be honest with you my trigonometry knowledge is very rusted, but I think that an Ellipse should have 5 degrees of freedom (I see this as x,y of both focuses+constraint on distance to both focuses from any point = major diameter, 2*2+1=5). Those 3 points can not be any 3 points, or you would have infinite solutions. You might start adding "constraints" to those points, (that one is on the major axis, for example)...

... There are many possible methods (and I welcome suggestions). My best option at this moment is, center point, point defining the major axis (with respect to the center point), so this is also the major radius, and then as third point, a point the ellipse must go through...
I guess there will be also an ellipse arc too for adding an angle constraint.
I plan to do it, but that is a next step.
I guess there will be also an ellipse arc too for adding an angle constraint.
That is part of the "maybe I do not manage to do it" :lol:

At this moment the constraints dealing with the center of the ellipse seem to work (This is the same as in a Circle, so the code was there). The challenge is the constraints applying to the edge. Oh, well, first I need to make the basics work and then I will focus on the rest...
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Sketcher: Ellipse support

Post by saso »

abdullah wrote:This is just to inform that I am getting busy with adding Ellipse support in the Sketcher. I am still in a very very very preliminary stage (... and I do not even know if I will be able to do it)...
I have lost count on all the things you do :) Really appreciate your efforts and everyone's else that are pushing this project forward at such a fast pace.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Sketcher: Ellipse support

Post by ulrich1a »

I would use the center point, end point of axis1 and a point the ellipse must go through, which defines the length of axis2.
In this way the center point of the ellipse and the rotation of the ellipse are defined. The rotation of the ellipse should not change, if axis2 becomes longer than axis1.
An arc of the ellipse will have two more constraints: start angle and end angle.

Ulrich
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Sketcher: Ellipse support

Post by NormandC »

This is great.

Next you will have to allow trimming of an ellipse. :P

Okay, I will shut up for now. ;)

Thanks for your work! It is really cool to see new contributors to FreeCAD code base.
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: Sketcher: Ellipse support

Post by quick61 »

Next you will have to allow trimming of an ellipse. :P
And then it's on to Bsplines and Bezier curves? :mrgreen:

Yes, great work and looking good. Awaiting an upload to start testing with bated breath....
This post made with 0.0% Micro$oft products - GOT LINUX?
Post Reply