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!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Ellipse support

Post by abdullah »

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.
Thanks for your work! It is really cool to see new contributors to FreeCAD code base.
Well, I only do simple things and mostly because the infrastructure is already there... the merit is of the ones that put the infraestructure in place...
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.
This is somehow what I had in mind and what I have implemented. Center point (click), another point defining one of the axis (click), a point where the elipse must go through (click) => calculate remaining axis, see which one is longer, create an appropriate ellipse.
Next you will have to allow trimming of an ellipse. :P
An arc of the ellipse will have two more constraints: start angle and end angle.
And then it's on to Bsplines and Bezier curves? :mrgreen:
Trimming and therefore Arc is stage 2, after normal ellipses work well with constraints.

Bsplines and Bezier curves, and hiperboles,... will those are not yet planned... let's see.

I started with ellipse support basically because Ulrich1a said it in a thread and then I saw a couple of Mantis tickets...

... so you already have done part of the job for Bsplines and Bezier... :lol:
Yes, great work and looking good. Awaiting an upload to start testing with bated breath....
You testing will be welcome!! ;)
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Sketcher: Ellipse support

Post by jmaustpc »

Hi Abduallah
Here is a quick version 1 slapped together set of icons for your Sketcher ellipse work.

There are the Element icons, sketcher icon, and constraints icons....some have alternative versions.

I have guessed what might be appropriate for an icon but as I don't know exactly yet how the GUI will function, we may want changes later.

for example
  • 1) I simply guessed that the ellipse will be created in the GUI in sketcher in much the same way as circle i.e. by clicking the points centre, then first radius and then second radius. If so then my ellipse with three points is appropriate, I think.
    2)To set constraints, assuming again that it will work similarly to circle, you would have two radii constraints perpendicular to each other. If so then there are three ways this could be done that I can think of...
    • a) one being just apply the current radius constraint from circle twice, ..in which case you would not need a new icon
      b) have two separate special ellipse radii constraints, a major and minor radius constraint as separate icons/functions....I made a pair of icons for this
      c) have a special "dual radii" constraint for Ellipses that has one icon/function ...perhaps similar to the current "lock" constraint........I made an icon for this
But at the least I thought these would give you something to work with for now.


Here they are all zipped up together
and here is a screen shot for anyone interested.....note that it includes some of the current icons for comparison.
Sketcher_Ellipse_constraints_and_elements_icons.jpg
Sketcher_Ellipse_constraints_and_elements_icons.jpg (51.25 KiB) Viewed 2486 times
Jim
mrlukeparry
Posts: 655
Joined: Fri Jul 22, 2011 8:37 pm
Contact:

Re: Sketcher: Ellipse support

Post by mrlukeparry »

abdullah wrote: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)...
This is what I meant - you will always have to define the centre and one of the major or minor axes. Anyway that sounds reasonable.
abdullah wrote: 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...
This was the bit I was unsure about more than anything especially with an overall axis rotation and being able to derive the error /distance function for the point on edge constraints. It's not going to be as trivial as a circle. I suppose googling helps - e.g. http://www.am.ub.edu/~robert/Documents/ellipse.pdf (section 5 for the ellipsoid) or probably better starting point is SketchFlat - http://cq.cx/sketchflat.pl
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Ellipse support

Post by abdullah »

Hi!

Lately I have been quite busy trying to remember high school calculus to derive the gradient of the distance to an ellipse with respect to all the seven parameters intervening (the 5 of the ellipse and the 2 extra of the point from which the distance to the ellipse has to be calculated... (more below)...
Here is a quick version 1 slapped together set of icons for your Sketcher ellipse work.
They are really nice!!
1) I simply guessed that the ellipse will be created in the GUI in sketcher in much the same way as circle i.e. by clicking the points centre, then first radius and then second radius. If so then my ellipse with three points is appropriate, I think.
It is not practical like that, because you will have to be constrained with the mouse to give a point on the minor axis... It works like that for center and an axis (we can go here with major for the icon drawing, but can be major or minor). Then, the last step is a point the ellipse must go through (any, no constraints, well, except that it can not be the same as the previously given one...). Depending on where you put this point, the axis you defined in the previous click will become the major or minor axis (depending on if the axis that you are implicitly forcing in this step is larger or smaller than the one before). I hope this is clear... it will be when I publish the code... which will be soon, see below...

Your icon is very nice. only it might make sense to put one of the points defining the axes a little bit disaligned with respect to where the real axis would be, so that it is clear that I am not asking for the axis... or just leave it like this, because the user is gonna see it anyway when using it. It is up to you.

I have not done constraints yet... but they seem ok... I really think the radius constraints should be applied separately... There is another one that is to set the angle between the X-Axis of the sketch and the major-Axis of the ellipse. I do not know if this should be simply done by reusing the normal angle constraint and icon...

I really much appreciate having an icon for the icon I push to create an ellipse.
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...
Yes I am quoting myself, just to say that I did not follow my own advice and instead started by probably the most difficult constraint the point on ellipse edge...
This was the bit I was unsure about more than anything especially with an overall axis rotation and being able to derive the error /distance function for the point on edge constraints. It's not going to be as trivial as a circle. I suppose googling helps - e.g. http://www.am.ub.edu/~robert/Documents/ellipse.pdf (section 5 for the ellipsoid) or probably better starting point is SketchFlat - http://cq.cx/sketchflat.pl
Yep I got that one. There are two nice ones. I am currently using this one, but it is the same:
http://wwwf.imperial.ac.uk/~rn/distance2ellipse.pdf

Sketchflat does not seem to support Ellipses (I downloaded the code, and did a grep -r -i ellipse * | less ).

So, basically. I have done some steps, but calculating the gradients of with respect to the 7 intervening variables is becoming a big challenge. I did some work, but I am not there (basically because the t parameter of the ellipse, see below, varies with respect to all 7 variables, i.e. if you move for example X_c to X_c+delta , you have a contributibution to the partial derivative coming from the fact that you are moving the ellipse, but you also have another contribution coming from t, as by moving the ellipse to the right changes the point in the ellipse where the distance is to be measured, in other words, t and X_c are not independent each other, in the sense that when you vary X_c you vary X_c and the t value, because the vector from the point to the curve hits the curve in a new position). This is even a little bit more complicated, as t is not part of the solver's variables, it is internal to the ellipse (it is a constraint in solving the equation), wherein the methods are boundary region methods not being constraint in finding the minimum... ummm... it seems like a need a reboot.

X(t)=X_c + a\,\cos t\,\cos \varphi - b\,\sin t\,\sin\varphi
Y(t)=Y_c + a\,\cos t\,\sin \varphi + b\,\sin t\,\cos\varphi

What is next?
- Applying my own advice on top (code first the "easier constraints").
- Make a version not supporting (from the user point of view the constraints that seem challenging at the moment)
- put the code in my git repository
- let you play with it and find bugs and solve them.
- Once the code is there and we all can see it, we can start thinking and discussing how/what to do. Then it will be easier for you to see the challenges I am facing...

I leave next my sage notebook code, if someone wants to check what I have been busy with...

Code: Select all

sage: a = var('a')
sage: b = var('b')
sage: t = var('t')
sage: phi = var('phi')
sage: X_c = var('X_c')
sage: Y_c = var('Y_c')
sage: Xt=X_c+a*cos(t)*cos(phi)-b*sin(t)*sin(phi)
sage: Yt=Y_c+a*cos(t)*sin(phi)+b*sin(t)*cos(phi)
sage: X_0 = var('X_0')
sage: Y_0 = var('Y_0')
sage: dXtdt= Xt.derivative(t)
sage: dYtdt= Yt.derivative(t)
sage: P=vector([X_0,Y_0])
sage: E=vector([Xt,Yt])
sage: dEdt=E.derivative(t)
sage: ((P-E)*dEdt).expand().simplify_trig()
(a^2 - b^2)*cos(t)*sin(t) - (b*cos(t)*sin(phi) + a*cos(phi)*sin(t))*X_0 + (b*cos(t)*sin(phi) + a*cos(phi)*sin(t))*X_c + (b*cos(phi)*cos(t) - a*sin(phi)*sin(t))*Y_0 - (b*cos(phi)*cos(t) - a*sin(phi)*sin(t))*Y_c
sage: thetafunc=((P-E)*dEdt).expand().simplify_trig()
sage: thetafunc.derivative(t).simplify_trig()
2*(a^2 - b^2)*cos(t)^2 - (a*cos(phi)*cos(t) - b*sin(phi)*sin(t))*X_0 + (a*cos(phi)*cos(t) - b*sin(phi)*sin(t))*X_c - (a*cos(t)*sin(phi) + b*cos(phi)*sin(t))*Y_0 + (a*cos(t)*sin(phi) + b*cos(phi)*sin(t))*Y_c - a^2 + b^2
sage: D=P-E
sage: norm(D)
sqrt(abs(-a*cos(phi)*cos(t) + b*sin(phi)*sin(t) + X_0 - X_c)^2 + abs(-a*cos(t)*sin(phi) - b*cos(phi)*sin(t) + Y_0 - Y_c)^2)
sage: DM=norm(D)
sage: DM_X0=DM.derivative(X_0)
sage: DM_Y0=DM.derivative(Y_0)
sage: DM_Xc=DM.derivative(X_c)
sage: DM_Yc=DM.derivative(Y_c)
sage: DM_a=DM.derivative(a)
sage: DM_b=DM.derivative(b)
sage: DM_phi=DM.derivative(phi)
sage: DM.derivative(t)
((b*cos(phi)*cos(t) - a*sin(phi)*sin(t))*(a*cos(t)*sin(phi) + b*cos(phi)*sin(t) - Y_0 + Y_c) - (a*cos(phi)*cos(t) - b*sin(phi)*sin(t) - X_0 + X_c)*(b*cos(t)*sin(phi) + a*cos(phi)*sin(t)))/sqrt(abs(-a*cos(phi)*cos(t) + b*sin(phi)*sin(t) + X_0 - X_c)^2 + abs(-a*cos(t)*sin(phi) - b*cos(phi)*sin(t) + Y_0 - Y_c)^2)
sage: thetafunc
(a^2 - b^2)*cos(t)*sin(t) - (b*cos(t)*sin(phi) + a*cos(phi)*sin(t))*X_0 + (b*cos(t)*sin(phi) + a*cos(phi)*sin(t))*X_c + (b*cos(phi)*cos(t) - a*sin(phi)*sin(t))*Y_0 - (b*cos(phi)*cos(t) - a*sin(phi)*sin(t))*Y_c
sage: constraint_eq = (thetafunc == 0)
sage: C_X0 = solve(constraint_eq,X_0)
sage: dtdx_0=C_X0[0].right().derivative(t).simplify_trig()
sage: FDM_X0=(DM_X0+thetafunc*(1/dtdx_0)).simplify_trig()
sage: FDM_X0.simplify_trig()
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{{\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{4} \sin\left(\phi\right) - {\left({\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \sin\left(\phi\right)\right)} \sin\left(t\right)^{2} - {\left({\left(a^{2} b - b^{3}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right) + Y_{c} a b + {\left({\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right)\right)} \sin\left(t\right)\right)} X_{0} + {\left({\left(a^{2} b - b^{3}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right) + {\left({\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right)\right)} \sin\left(t\right)\right)} X_{c} - {\left(a^{2} b \cos\left(\phi\right) \cos\left(t\right) - a b^{2} \sin\left(\phi\right) \sin\left(t\right) - X_{0} a b + X_{c} a b\right)} Y_{0} + {\left(a^{2} b \cos\left(\phi\right) \cos\left(t\right) - a b^{2} \sin\left(\phi\right) \sin\left(t\right) + X_{c} a b\right)} Y_{c} - {\left({\left(a^{4} - a^{2} b^{2}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right) - {\left({\left(a^{4} - a^{2} b^{2}\right)} \cos\left(\phi\right)^{2} - {\left(a^{2} b^{2} - b^{4}\right)} \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{3}\right)} \sin\left(t\right) - {\left({\left(a^{2} b^{2} - b^{4}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} \sin\left(t\right) + 2 \, {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + {\left(a^{4} - a^{2} b^{2}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(t\right)^{3} - {\left(b^{3} \cos\left(t\right)^{3} \sin\left(\phi\right)^{3} + 3 \, a b^{2} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + a^{3} \cos\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} X_{0} + {\left(b^{3} \cos\left(t\right)^{3} \sin\left(\phi\right)^{3} + 3 \, a b^{2} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + a^{3} \cos\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} X_{c} + {\left(b^{3} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} - a^{3} \cos\left(\phi\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} + {\left(2 \, a b^{2} \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a b^{2} \sin\left(\phi\right)^{3}\right)} \cos\left(t\right)^{2} \sin\left(t\right) + {\left(a^{2} b \cos\left(\phi\right)^{3} - 2 \, a^{2} b \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} Y_{0} - {\left(b^{3} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} - a^{3} \cos\left(\phi\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} + {\left(2 \, a b^{2} \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a b^{2} \sin\left(\phi\right)^{3}\right)} \cos\left(t\right)^{2} \sin\left(t\right) + {\left(a^{2} b \cos\left(\phi\right)^{3} - 2 \, a^{2} b \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} Y_{c}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}{{\left({\left(a^{2} b - b^{3}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right) - Y_{0} a b + Y_{c} a b + {\left({\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right)\right)} \sin\left(t\right)\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}</script></html>
sage: C_Y0 = solve(constraint_eq,Y_0)
sage: dtdy_0=C_Y0[0].right().derivative(t).simplify_trig()
sage: FDM_Y0=(DM_Y0+thetafunc*(1/dtdy_0)).simplify_trig()
sage: FDM_Y0
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{{\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{4} \sin\left(\phi\right) - {\left({\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \sin\left(\phi\right)\right)} \sin\left(t\right)^{2} - {\left(a^{2} b \cos\left(t\right) \sin\left(\phi\right) + a b^{2} \cos\left(\phi\right) \sin\left(t\right) + Y_{c} a b\right)} X_{0} + {\left(a^{2} b \cos\left(t\right) \sin\left(\phi\right) + a b^{2} \cos\left(\phi\right) \sin\left(t\right)\right)} X_{c} - {\left({\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{3} - X_{0} a b + X_{c} a b - {\left({\left(a^{3} - a b^{2}\right)} \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} - a b^{2}\right)} \sin\left(\phi\right)\right)} \sin\left(t\right)\right)} Y_{0} + {\left({\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{3} + X_{c} a b - {\left({\left(a^{3} - a b^{2}\right)} \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} - a b^{2}\right)} \sin\left(\phi\right)\right)} \sin\left(t\right)\right)} Y_{c} + {\left({\left({\left(a^{2} b^{2} - b^{4}\right)} \cos\left(\phi\right)^{2} - {\left(a^{4} - a^{2} b^{2}\right)} \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{3} + {\left(a^{4} - a^{2} b^{2}\right)} \cos\left(t\right) \sin\left(\phi\right)^{2}\right)} \sin\left(t\right) + {\left({\left(a^{2} b^{2} - b^{4}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(t\right) - 2 \, {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + {\left(a^{4} - a^{2} b^{2}\right)} \cos\left(t\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} - {\left(b^{3} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) + a^{3} \cos\left(\phi\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} + {\left(a b^{2} \cos\left(\phi\right)^{3} - 2 \, a b^{2} \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{2} \sin\left(t\right) - {\left(2 \, a^{2} b \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a^{2} b \sin\left(\phi\right)^{3}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} X_{0} + {\left(b^{3} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) + a^{3} \cos\left(\phi\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} + {\left(a b^{2} \cos\left(\phi\right)^{3} - 2 \, a b^{2} \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{2} \sin\left(t\right) - {\left(2 \, a^{2} b \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a^{2} b \sin\left(\phi\right)^{3}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} X_{c} + {\left(b^{3} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} - 3 \, a b^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{2} - a^{3} \sin\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} Y_{0} - {\left(b^{3} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} - 3 \, a b^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{2} - a^{3} \sin\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} Y_{c}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}{{\left({\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{3} - X_{0} a b + X_{c} a b - {\left({\left(a^{3} - a b^{2}\right)} \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} - a b^{2}\right)} \sin\left(\phi\right)\right)} \sin\left(t\right)\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}</script></html>
sage: C_XC = solve(constraint_eq,X_c)
sage: dtdx_c=C_XC[0].right().derivative(t).simplify_trig()
sage: FDM_XC=(DM_Xc+thetafunc*(1/dtdx_c)).simplify_trig()
sage: FDM_XC
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{{\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{4} \sin\left(\phi\right) - {\left({\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \sin\left(\phi\right)\right)} \sin\left(t\right)^{2} - {\left({\left(a^{2} b - b^{3}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right) + Y_{c} a b + {\left({\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right)\right)} \sin\left(t\right)\right)} X_{0} + {\left({\left(a^{2} b - b^{3}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right) + {\left({\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right)\right)} \sin\left(t\right)\right)} X_{c} - {\left(a^{2} b \cos\left(\phi\right) \cos\left(t\right) - a b^{2} \sin\left(\phi\right) \sin\left(t\right) - X_{0} a b + X_{c} a b\right)} Y_{0} + {\left(a^{2} b \cos\left(\phi\right) \cos\left(t\right) - a b^{2} \sin\left(\phi\right) \sin\left(t\right) + X_{c} a b\right)} Y_{c} - {\left({\left(a^{4} - a^{2} b^{2}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right) - {\left({\left(a^{4} - a^{2} b^{2}\right)} \cos\left(\phi\right)^{2} - {\left(a^{2} b^{2} - b^{4}\right)} \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{3}\right)} \sin\left(t\right) - {\left({\left(a^{2} b^{2} - b^{4}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} \sin\left(t\right) + 2 \, {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + {\left(a^{4} - a^{2} b^{2}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(t\right)^{3} - {\left(b^{3} \cos\left(t\right)^{3} \sin\left(\phi\right)^{3} + 3 \, a b^{2} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + a^{3} \cos\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} X_{0} + {\left(b^{3} \cos\left(t\right)^{3} \sin\left(\phi\right)^{3} + 3 \, a b^{2} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + a^{3} \cos\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} X_{c} + {\left(b^{3} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} - a^{3} \cos\left(\phi\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} + {\left(2 \, a b^{2} \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a b^{2} \sin\left(\phi\right)^{3}\right)} \cos\left(t\right)^{2} \sin\left(t\right) + {\left(a^{2} b \cos\left(\phi\right)^{3} - 2 \, a^{2} b \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} Y_{0} - {\left(b^{3} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} - a^{3} \cos\left(\phi\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} + {\left(2 \, a b^{2} \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a b^{2} \sin\left(\phi\right)^{3}\right)} \cos\left(t\right)^{2} \sin\left(t\right) + {\left(a^{2} b \cos\left(\phi\right)^{3} - 2 \, a^{2} b \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} Y_{c}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}{{\left({\left(a^{2} b - b^{3}\right)} \cos\left(t\right)^{3} \sin\left(\phi\right) - Y_{0} a b + Y_{c} a b + {\left({\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \cos\left(\phi\right)\right)} \sin\left(t\right)\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}</script></html>
sage: C_YC = solve(constraint_eq,Y_c)
sage: dtdy_c=C_YC[0].right().derivative(t).simplify_trig()
sage: FDM_YC=(DM_Yc+thetafunc*(1/dtdy_c)).simplify_trig()
sage: FDM_YC
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{{\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} - {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{4} - {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{2} b^{2} - b^{4}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(t\right) + {\left({\left(a^{2} b^{2} - b^{4}\right)} \cos\left(\phi\right)^{2} - {\left(a^{4} - a^{2} b^{2}\right)} \sin\left(\phi\right)^{2}\right)} \cos\left(t\right) \sin\left(t\right)^{3} + {\left(a^{2} b \cos\left(t\right) \sin\left(\phi\right) + a b^{2} \cos\left(\phi\right) \sin\left(t\right) + Y_{c} a b\right)} X_{0} - {\left(a^{2} b \cos\left(t\right) \sin\left(\phi\right) + a b^{2} \cos\left(\phi\right) \sin\left(t\right)\right)} X_{c} - {\left({\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \sin\left(\phi\right) \sin\left(t\right)^{3} + X_{0} a b - X_{c} a b - {\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)\right)} Y_{0} + {\left({\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{2} - {\left(a^{3} - a b^{2}\right)} \sin\left(\phi\right) \sin\left(t\right)^{3} - X_{c} a b - {\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)\right)} Y_{c} - {\left({\left(a^{2} b^{2} - b^{4}\right)} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(t\right) - 2 \, {\left(a^{3} b - a b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + {\left(a^{4} - a^{2} b^{2}\right)} \cos\left(t\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} - {\left(b^{3} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) + a^{3} \cos\left(\phi\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} + {\left(a b^{2} \cos\left(\phi\right)^{3} - 2 \, a b^{2} \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{2} \sin\left(t\right) - {\left(2 \, a^{2} b \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a^{2} b \sin\left(\phi\right)^{3}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} X_{0} + {\left(b^{3} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) + a^{3} \cos\left(\phi\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} + {\left(a b^{2} \cos\left(\phi\right)^{3} - 2 \, a b^{2} \cos\left(\phi\right) \sin\left(\phi\right)^{2}\right)} \cos\left(t\right)^{2} \sin\left(t\right) - {\left(2 \, a^{2} b \cos\left(\phi\right)^{2} \sin\left(\phi\right) - a^{2} b \sin\left(\phi\right)^{3}\right)} \cos\left(t\right) \sin\left(t\right)^{2}\right)} X_{c} + {\left(b^{3} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} - 3 \, a b^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{2} - a^{3} \sin\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} Y_{0} - {\left(b^{3} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} - 3 \, a b^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + 3 \, a^{2} b \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right)^{2} \sin\left(t\right)^{2} - a^{3} \sin\left(\phi\right)^{3} \sin\left(t\right)^{3}\right)} Y_{c}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}{{\left({\left(a^{2} b - b^{3}\right)} \cos\left(\phi\right) \cos\left(t\right)^{3} - X_{0} a b + X_{c} a b - {\left({\left(a^{3} - a b^{2}\right)} \cos\left(t\right)^{2} \sin\left(\phi\right) - {\left(a^{3} - a b^{2}\right)} \sin\left(\phi\right)\right)} \sin\left(t\right)\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}</script></html>
sage: C_a = solve(constraint_eq,a)
sage: dtda=C_a[0].right().derivative(t).simplify_trig()
sage: FDM_a=(DM_a+thetafunc*(1/dtda)).simplify_trig()
sage: FDM_a
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{2 \, X_{c} a b \cos\left(t\right)^{6} \sin\left(\phi\right) - X_{0}^{3} \cos\left(\phi\right)^{3} \cos\left(t\right) \sin\left(t\right)^{3} + X_{c}^{3} \cos\left(\phi\right)^{3} \cos\left(t\right) \sin\left(t\right)^{3} + {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{0}^{3} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} - {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c}^{3} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} + {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{5} \sin\left(\phi\right) + 3 \, X_{c} \cos\left(\phi\right)^{3} \cos\left(t\right) \sin\left(t\right)^{3} + a \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{3} + 3 \, Y_{c} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3}\right)} X_{0}^{2} + {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{5} \sin\left(\phi\right) + a \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{3}\right)} X_{c}^{2} - {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{5} \sin\left(\phi\right) + 3 \, {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} - 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{0} \cos\left(t\right) \sin\left(t\right)^{3} + 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c} \cos\left(t\right) \sin\left(t\right)^{3} + {\left(a \cos\left(\phi\right)^{2} - a\right)} \cos\left(t\right)^{2} \sin\left(t\right)^{3}\right)} Y_{0}^{2} - {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{5} \sin\left(\phi\right) + 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c} \cos\left(t\right) \sin\left(t\right)^{3} + {\left(a \cos\left(\phi\right)^{2} - a\right)} \cos\left(t\right)^{2} \sin\left(t\right)^{3}\right)} Y_{c}^{2} - {\left(2 \, a b \cos\left(t\right)^{6} \sin\left(\phi\right) + 3 \, X_{c}^{2} \cos\left(\phi\right)^{3} \cos\left(t\right) \sin\left(t\right)^{3} - 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} Y_{c}^{2} \cos\left(t\right) \sin\left(t\right)^{3} + 2 \, {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{5} \sin\left(\phi\right) + a \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{3}\right)} X_{c} + 2 \, {\left(3 \, X_{c} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} + a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} - {\left(2 \, b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{5}\right)} Y_{c}\right)} X_{0} + {\left(2 \, a b \cos\left(\phi\right) \cos\left(t\right)^{6} - 3 \, X_{0}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} - 3 \, X_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} + 3 \, {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c}^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} + 2 \, {\left(3 \, X_{c} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} + a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} - {\left(2 \, b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{5} - 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} Y_{c} \cos\left(t\right) \sin\left(t\right)^{3}\right)} X_{0} - 2 \, {\left(a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} - {\left(2 \, b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{5}\right)} X_{c} + 2 \, {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{5} \sin\left(\phi\right) + 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c} \cos\left(t\right) \sin\left(t\right)^{3} + {\left(a \cos\left(\phi\right)^{2} - a\right)} \cos\left(t\right)^{2} \sin\left(t\right)^{3}\right)} Y_{c}\right)} Y_{0} - {\left(2 \, a b \cos\left(\phi\right) \cos\left(t\right)^{6} - 3 \, X_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3} - 2 \, {\left(a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{3} - {\left(2 \, b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{5}\right)} X_{c}\right)} Y_{c} + {\left(X_{0}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(t\right)^{2} + X_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(t\right)^{2} + X_{c} a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{0}^{2} \cos\left(t\right) \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c}^{2} \cos\left(t\right) \sin\left(t\right)^{2} - {\left(2 \, X_{c} \cos\left(\phi\right)^{2} \cos\left(t\right) \sin\left(t\right)^{2} + a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2} + 2 \, Y_{c} \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} X_{0} + {\left(2 \, X_{0} \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} - 2 \, X_{c} \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} - a \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + 2 \, {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c} \cos\left(t\right) \sin\left(t\right)^{2}\right)} Y_{0} + {\left(2 \, X_{c} \cos\left(\phi\right) \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + a \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{c} - 2 \, {\left({\left(a^{2} - b^{2}\right)} \cos\left(t\right)^{3} \sin\left(t\right)^{2} - {\left(b \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) + a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2}\right)} X_{0} + {\left(b \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) + a \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2}\right)} X_{c} + {\left(b \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(t\right) - a \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{0} - {\left(b \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(t\right) - a \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{c}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}\right)} \sqrt{-4 \, X_{c} b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + X_{0}^{2} \cos\left(\phi\right)^{2} \sin\left(t\right)^{2} + X_{c}^{2} \cos\left(\phi\right)^{2} \sin\left(t\right)^{2} + 4 \, b^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{0}^{2} \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c}^{2} \sin\left(t\right)^{2} + 2 \, {\left(2 \, b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) - X_{c} \cos\left(\phi\right)^{2} \sin\left(t\right)^{2} - Y_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} X_{0} - 2 \, {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right) - X_{0} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + X_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} Y_{c} \sin\left(t\right)^{2}\right)} Y_{0} + 2 \, {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right) + X_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{c}}}{{\left(2 \, X_{c} b \cos\left(t\right)^{4} \sin\left(\phi\right) + X_{0}^{2} \cos\left(\phi\right)^{2} \sin\left(t\right)^{3} + X_{c}^{2} \cos\left(\phi\right)^{2} \sin\left(t\right)^{3} + Y_{0}^{2} \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} + Y_{c}^{2} \sin\left(\phi\right)^{2} \sin\left(t\right)^{3} - 2 \, {\left(b \cos\left(t\right)^{4} \sin\left(\phi\right) + X_{c} \cos\left(\phi\right)^{2} \sin\left(t\right)^{3} + Y_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{3}\right)} X_{0} + 2 \, {\left(b \cos\left(\phi\right) \cos\left(t\right)^{4} + X_{0} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{3} - X_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{3} - Y_{c} \sin\left(\phi\right)^{2} \sin\left(t\right)^{3}\right)} Y_{0} - 2 \, {\left(b \cos\left(\phi\right) \cos\left(t\right)^{4} - X_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{3}\right)} Y_{c} - \sqrt{-4 \, X_{c} b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + X_{0}^{2} \cos\left(\phi\right)^{2} \sin\left(t\right)^{2} + X_{c}^{2} \cos\left(\phi\right)^{2} \sin\left(t\right)^{2} + 4 \, b^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{2} + Y_{0}^{2} \sin\left(\phi\right)^{2} \sin\left(t\right)^{2} + Y_{c}^{2} \sin\left(\phi\right)^{2} \sin\left(t\right)^{2} + 2 \, {\left(2 \, b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) - X_{c} \cos\left(\phi\right)^{2} \sin\left(t\right)^{2} - Y_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} X_{0} - 2 \, {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right) - X_{0} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + X_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2} + Y_{c} \sin\left(\phi\right)^{2} \sin\left(t\right)^{2}\right)} Y_{0} + 2 \, {\left(2 \, b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right) + X_{c} \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{c}} {\left(X_{0} \cos\left(\phi\right) \sin\left(t\right)^{2} - X_{c} \cos\left(\phi\right) \sin\left(t\right)^{2} + Y_{0} \sin\left(\phi\right) \sin\left(t\right)^{2} - Y_{c} \sin\left(\phi\right) \sin\left(t\right)^{2}\right)}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}</script></html>
sage: C_b = solve(constraint_eq,b)
sage: dtdb=C_b[0].right().derivative(t).simplify_trig()
sage: FDM_b=(DM_b+thetafunc*(1/dtdb)).simplify_trig()
sage: FDM_b
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{Y_{0}^{3} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} \sin\left(t\right) - Y_{c}^{3} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} \sin\left(t\right) + 2 \, X_{c} a b \cos\left(\phi\right) \sin\left(t\right)^{6} + {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{0}^{3} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c}^{3} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - {\left(2 \, a \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{5} + 3 \, {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} Y_{c} \cos\left(t\right)^{3} \sin\left(t\right) - {\left(b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{3} \sin\left(t\right)^{2}\right)} X_{0}^{2} - {\left(2 \, a \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{5} - {\left(b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{3} \sin\left(t\right)^{2}\right)} X_{c}^{2} - {\left(3 \, Y_{c} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} \sin\left(t\right) + 3 \, X_{0} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - 3 \, X_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) + b \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(t\right)^{2} - 2 \, a \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{5}\right)} Y_{0}^{2} + {\left(3 \, X_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - b \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(t\right)^{2} + 2 \, a \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{5}\right)} Y_{c}^{2} - {\left(3 \, Y_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) + 2 \, a b \cos\left(\phi\right) \sin\left(t\right)^{6} - 3 \, {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c}^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - 2 \, {\left(2 \, a \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{5} - {\left(b \cos\left(\phi\right)^{2} - b\right)} \cos\left(t\right)^{3} \sin\left(t\right)^{2}\right)} X_{c} + 2 \, {\left(b \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right)^{2} + 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c} \cos\left(t\right)^{3} \sin\left(t\right) + {\left(2 \, a \cos\left(\phi\right)^{2} - a\right)} \sin\left(t\right)^{5}\right)} Y_{c}\right)} X_{0} + {\left(3 \, Y_{c}^{2} \cos\left(\phi\right)^{3} \cos\left(t\right)^{3} \sin\left(t\right) - 2 \, a b \sin\left(\phi\right) \sin\left(t\right)^{6} - 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{0}^{2} \cos\left(t\right)^{3} \sin\left(t\right) - 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c}^{2} \cos\left(t\right)^{3} \sin\left(t\right) + 2 \, {\left(3 \, Y_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) + b \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right)^{2} + 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c} \cos\left(t\right)^{3} \sin\left(t\right) + {\left(2 \, a \cos\left(\phi\right)^{2} - a\right)} \sin\left(t\right)^{5}\right)} X_{0} - 2 \, {\left(b \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right)^{2} + {\left(2 \, a \cos\left(\phi\right)^{2} - a\right)} \sin\left(t\right)^{5}\right)} X_{c} - 2 \, {\left(3 \, X_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right) - b \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} \sin\left(t\right)^{2} + 2 \, a \cos\left(\phi\right) \sin\left(\phi\right) \sin\left(t\right)^{5}\right)} Y_{c}\right)} Y_{0} + {\left(2 \, a b \sin\left(\phi\right) \sin\left(t\right)^{6} + 3 \, {\left(\cos\left(\phi\right)^{3} - \cos\left(\phi\right)\right)} X_{c}^{2} \cos\left(t\right)^{3} \sin\left(t\right) + 2 \, {\left(b \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) \sin\left(t\right)^{2} + {\left(2 \, a \cos\left(\phi\right)^{2} - a\right)} \sin\left(t\right)^{5}\right)} X_{c}\right)} Y_{c} - {\left(Y_{0}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(t\right) + Y_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(t\right) - X_{c} b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{0}^{2} \cos\left(t\right)^{2} \sin\left(t\right) - {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c}^{2} \cos\left(t\right)^{2} \sin\left(t\right) + {\left(2 \, Y_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + 2 \, {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c} \cos\left(t\right)^{2} \sin\left(t\right)\right)} X_{0} - {\left(2 \, Y_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} \sin\left(t\right) + 2 \, X_{0} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) - 2 \, X_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) + b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2}\right)} Y_{0} - {\left(2 \, X_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right) - b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2}\right)} Y_{c} + 2 \, {\left({\left(a^{2} - b^{2}\right)} \cos\left(t\right)^{2} \sin\left(t\right)^{3} - {\left(b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + a \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{3}\right)} X_{0} + {\left(b \cos\left(t\right)^{2} \sin\left(\phi\right) \sin\left(t\right)^{2} + a \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{3}\right)} X_{c} + {\left(b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2} - a \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3}\right)} Y_{0} - {\left(b \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(t\right)^{2} - a \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{3}\right)} Y_{c}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}\right)} \sqrt{Y_{0}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} + Y_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} + 4 \, X_{c} a \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{2} + 4 \, a^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{0}^{2} \cos\left(t\right)^{2} - {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c}^{2} \cos\left(t\right)^{2} + 2 \, {\left(Y_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - 2 \, a \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{2} + {\left(\cos\left(\phi\right)^{2} - 1\right)} X_{c} \cos\left(t\right)^{2}\right)} X_{0} - 2 \, {\left(Y_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} + X_{0} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - X_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) + 2 \, a \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{0} - 2 \, {\left(X_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - 2 \, a \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{c}}}{{\left(Y_{0}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} + Y_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} + X_{0}^{2} \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} + X_{c}^{2} \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} - 2 \, X_{c} a \cos\left(\phi\right) \sin\left(t\right)^{4} + 2 \, {\left(Y_{c} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) - X_{c} \cos\left(t\right)^{3} \sin\left(\phi\right)^{2} + a \cos\left(\phi\right) \sin\left(t\right)^{4}\right)} X_{0} - 2 \, {\left(Y_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{3} + X_{0} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) - X_{c} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) - a \sin\left(\phi\right) \sin\left(t\right)^{4}\right)} Y_{0} - 2 \, {\left(X_{c} \cos\left(\phi\right) \cos\left(t\right)^{3} \sin\left(\phi\right) + a \sin\left(\phi\right) \sin\left(t\right)^{4}\right)} Y_{c} - \sqrt{Y_{0}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} + Y_{c}^{2} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} + X_{0}^{2} \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} + X_{c}^{2} \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} + 4 \, X_{c} a \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{2} + 4 \, a^{2} \cos\left(t\right)^{2} \sin\left(t\right)^{2} + 2 \, {\left(Y_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - X_{c} \cos\left(t\right)^{2} \sin\left(\phi\right)^{2} - 2 \, a \cos\left(\phi\right) \cos\left(t\right) \sin\left(t\right)^{2}\right)} X_{0} - 2 \, {\left(Y_{c} \cos\left(\phi\right)^{2} \cos\left(t\right)^{2} + X_{0} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - X_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) + 2 \, a \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{0} - 2 \, {\left(X_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} \sin\left(\phi\right) - 2 \, a \cos\left(t\right) \sin\left(\phi\right) \sin\left(t\right)^{2}\right)} Y_{c}} {\left(Y_{0} \cos\left(\phi\right) \cos\left(t\right)^{2} - Y_{c} \cos\left(\phi\right) \cos\left(t\right)^{2} - X_{0} \cos\left(t\right)^{2} \sin\left(\phi\right) + X_{c} \cos\left(t\right)^{2} \sin\left(\phi\right)\right)}\right)} \sqrt{{\left| -a \cos\left(\phi\right) \cos\left(t\right) + b \sin\left(\phi\right) \sin\left(t\right) + X_{0} - X_{c} \right|}^{2} + {\left| -a \cos\left(t\right) \sin\left(\phi\right) - b \cos\left(\phi\right) \sin\left(t\right) + Y_{0} - Y_{c} \right|}^{2}}}</script></html>
sage: C_phi = solve(constraint_eq,phi)
sage: C_phi
<html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\left[\sin\left(\phi\right) = \frac{a^{2} \cos\left(t\right) \sin\left(t\right) - b^{2} \cos\left(t\right) \sin\left(t\right) + {\left({\left(Y_{0} - Y_{c}\right)} b \cos\left(t\right) - {\left(X_{0} - X_{c}\right)} a \sin\left(t\right)\right)} \cos\left(\phi\right)}{{\left(X_{0} - X_{c}\right)} b \cos\left(t\right) + {\left(Y_{0} - Y_{c}\right)} a \sin\left(t\right)}\right]</script></html>
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Sketcher: Ellipse support

Post by abdullah »

Hey Jim!! Wrong file? :shock: This is not those wonderful ellipse icons I see above :lol:
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Sketcher: Ellipse support

Post by jmaustpc »

abdullah wrote:Hey Jim!! Wrong file? :shock: This is not those wonderful ellipse icons I see above :lol:
OOps.! There were still for you though in the other topic "selecting element via their constraints"...I wonder if I switched the other topic's icons as well?

Here is the correct file

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

Re: Sketcher: Ellipse support

Post by jmaustpc »

abdullah wrote:It is not practical like that, because you will have to be constrained with the mouse to give a point on the minor axis... It works like that for center and an axis (we can go here with major for the icon drawing, but can be major or minor). Then, the last step is a point the ellipse must go through (any, no constraints, well, except that it can not be the same as the previously given one...). Depending on where you put this point, the axis you defined in the previous click will become the major or minor axis (depending on if the axis that you are implicitly forcing in this step is larger or smaller than the one before). I hope this is clear...
OK, thanks for the explanation, perfectly clear, :) I remember seeing this construction option for a circle and/or an ellipse, in OCC somewhere I think it was, when I was working on the circle or Ellipse in Part WB.

abdullah wrote:Your icon is very nice. only it might make sense to put one of the points defining the axes a little bit disaligned with respect to where the real axis would be, so that it is clear that I am not asking for the axis...
I agree, that was one of the things I was thing about when I was asking about the construction methods.
abdullah wrote:I have not done constraints yet... but they seem ok... I really think the radius constraints should be applied separately... There is another one that is to set the angle between the X-Axis of the sketch and the major-Axis of the ellipse. I do not know if this should be simply done by reusing the normal angle constraint and icon...
When I first thought about this I assumed that the Ellipse would be constructed via three points (as you said it will be) with mouse clicks. Then without thinking about it I assumed that it would be then constraint via constraining those construction points. However this would have been a "profiles" work flow not an "element" work flow.

It sounds like an ellipse in sketcher is going be constrained via an axis and two radii. If so would the axis have a graphical representation similar to the sketch axes? If a user could just select the ellipse axis and one of the sketch axes and use the current angle constraint. One complication that springs to my mind though is the Ellipse axis is actually the major axis and hence is defined by a line going through the centre point and the circumference at the two points of major radius, right? If so, then when applying the two radii constraints to an Ellipse in sketcher, you would have to not allow the minor radius to be longer than the major radius or other wise the axis would now be perpendicular to the real major axis. I wonder if that would matter? it would seem at least inconsistent behaviour and hence possibly have unexpected consequences. If I am making sense so far, then I think that means we need two new constraints named "major radius" and "minor radius", which would only apply to Ellipses and Elliptical Arcs.

Which now brings up another question, would Elliptical Arcs, be defined by the same things as the Ellipse of which they are a part (Major and Minor radii, Major Axis) as well as a "start and stop angle" (like the Part Ellipse). And would they be constrained in sketcher again with the two radii constraints, and angle constraint on the major axis and then whatever constraints on the start and end points?


Jim
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Sketcher: Ellipse support

Post by wmayer »

So, basically. I have done some steps, but calculating the gradients of with respect to the 7 intervening variables is becoming a big challenge. I did some work, but I am not there (basically because the t parameter of the ellipse, see below, varies with respect to all 7 variables, i.e. if you move for example X_c to X_c+delta , you have a contributibution to the partial derivative coming from the fact that you are moving the ellipse, but you also have another contribution coming from t, as by moving the ellipse to the right changes the point in the ellipse where the distance is to be measured, in other words, t and X_c are not independent each other, in the sense that when you vary X_c you vary X_c and the t value, because the vector from the point to the curve hits the curve in a new position). This is even a little bit more complicated, as t is not part of the solver's variables, it is internal to the ellipse (it is a constraint in solving the equation), wherein the methods are boundary region methods not being constraint in finding the minimum... ummm... it seems like a need a reboot.

X(t)=X_c + a\,\cos t\,\cos \varphi - b\,\sin t\,\sin\varphi
Y(t)=Y_c + a\,\cos t\,\sin \varphi + b\,\sin t\,\cos\varphi
Sorry, but I don't get the point why X_c and Y_c should depend on t. See here:
your parameters for the solver are basically X_c, Y_c, a, b and phi. t is the parameter in the range [0, 2*Pi] and is only needed to render the geometry but the solver doesn't need to know it.
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Sketcher: Ellipse support

Post by ulrich1a »

After looking into the ellipse equation I got an idea, why the ellipse was not coded in the sketcher. When drawing the ellipse the first time, there may be the freedom to decide which axis should be the major axis.
But when the ellipse exist, the equations allways assume: a > b. Any constraint that requires the exchange of major and minor axis, makes the equation invalid. Another equation has to be set up for this case.
I currently have no idea, how this can be solved in a general way. To get the ellipse into the sketcher, the solver may reject solutions that have to exchange major with minor axis with a helpfull message.
Or does someone know a solution?

Ulrich
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Sketcher: Ellipse support

Post by bejant »

It is this way in the Draft WB, the minor and major axes cannot be switched from one to another after the ellipse is created or the following error message is issued:

Traceback (most recent call last):
File "/usr/lib/freecad/Mod/Draft/Draft.py", line 3920, in execute
msg(translate("Error: Major radius is smaller than the minor radius"))
<type 'exceptions.NameError'>: global name 'msg' is not defined


OS: Ubuntu 12.04.5 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.15.3979 (Git)
Branch: master
Hash: e5a54d0791b92825b1df0548036476d2f5b9e449
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0
Post Reply