Substitute control point spline for ellipse

Substitute control point spline for ellipse

edgemarston
Advocate Advocate
2,071 Views
15 Replies
Message 1 of 16

Substitute control point spline for ellipse

edgemarston
Advocate
Advocate

Haven't seen this posted yet, so thought I'd put up a neat trick I stumbled on. There are times when I've wanted a sketch to have more flexibility than an ellipse, but still have an ellipse contained in the superset of options. Here's how to do it:

 

ellipse and spline conversion.png

 

In this sketch, the ellipse has major axis (2a) = 100mm and minor axis (2b) = 60mm. You can get an equivalent 6-point control point spline (covering half the ellipse) by using the dimensions shown above.

 

  • The bottom horizontal segment has length 2a/2 = 50mm
  • The bottom vertical segment has length 2b/3 = 20mm
  • The top vertical segment has length 2b/3*.935 = 18.70mm

To be clear, this works for any ellipse with major axis 2a and minor axis 2b. I tried finding an easy algebraic explanation for how this works and had trouble. If someone can explain it in the comments, that would be great!

2,072 Views
15 Replies
Replies (15)
Message 2 of 16

MichaelT_123
Advisor
Advisor

 Hi Mr EdgeMarston


### If someone can explain it in the comments, that would be great! ###
Consider searching for Rational Bézier curves and ellipses. Wiki is a good starting point.

Regards
MichaelT

PS.
I believe that F360 uses R-Bézier as a representation of all conic curves ... on the menu.

MichaelT
0 Likes
Message 3 of 16

Drewpan
Advisor
Advisor

Hi,

 

Since I am a student and I am still learning, under what circumstances would I need to create an ellipse that

was a control point spline? Especially a 6 point spline when the Gurus tell me that with splines it is a case of

less points is more. What advantage has a spline over an ellipse? I have not done nearly enough modelling to

have come across many finer points of this arcane art - which is why I am asking.

 

Cheers

 

Andrew

0 Likes
Message 4 of 16

edgemarston
Advocate
Advocate

Most of the time, normal ellipses should work fine. There are a few situations where I like to have the spline option:

 

1. If I'm only using half the ellipse anyway, the spline might end up feeling like a more elegant sketch (since the other half of the ellipse would be "wasted").

2. If I want to have more flexibility, for example maybe I want to extrude a feature where the curvature is fatter or skinnier than an ellipse, but I'm not sure yet exactly what shape I will ultimately want. Then you can use a spline to keep that optionality for later.

3. Fusion is kind of buggy with tangency constraints, and sometimes you can create the constraint you want better by using the construction lines of the spline rather than the ellipse itself.

 

I wouldn't say this is a super common trick though, mostly I just thought it was neat to find a substitute. And you are certainly right that when modeling with splines, it is good practice to use the fewest points possible to achieve your design objective.

0 Likes
Message 5 of 16

Drewpan
Advisor
Advisor

Hi,

 

Isn't a fatter or skinnier ellipse just an ellipse with different proportions or are you talking about modifying

it to more of an egg than an oval? I have been using splines quite a bit in my latest project and they drive me

insane (insane-er?), surely a fatter or skinnier ellipse is still an ellipse. Wouldn't a nice clean mathematically

calculated ellipse be better than fiddling with splines if this were the case?

 

I know exactly what you mean with tangency constraints but I feel that the clean generated ellipse avoids the

problem.

 

Cheers

 

Andrew

0 Likes
Message 6 of 16

MichaelT_123
Advisor
Advisor

Hi Fellows,

Ellipse is the enigma of Queen Geometry … even more so than a circle. 

It is not a surprise that it causes problems in mathematics, CAD, … inducing many questions.

The good news is that although generally unfathomable, it is still approachable in most common situations … also in CAD software (including F360).

Where is the main problem? The problem is brought by π!  … as the ellipse is a trigonometric curve founded by trigonometric functions, while all computations are based on polynomial functions (even π). Trigonometric and polynomial functionsare incompatible; thus, switching from one domain to another always brings some uncertainty.

Yes, ellipses (and, in general, conic curves) in F360 are internally defined as polynomials (Bézier splines) and encapsulated in their respective metaphors, like ellipse-related polynomials are given ellipse-axes. It dramatically simplifies many CAD operations … on, in reality, polynomial functions!

Hence, how precise is conic-curves representation by splines (polynomials function segments)?

I would say that unless you are dealing with extreme accuracy, the calculations done in F360 should suffice.

The problem starts to become visible around σ ~ 10⁻⁸. Thus, it is somewhat distant for designers who adore sketches as a data entry method, which truncates the precision to about σ ~ 10⁻⁶. The situation is not so crystal clear if other more sophisticated design methods are in use (e.g. via API). Note that derivatives/curvatures/tangents of even slightly misrepresented curves will amplify the respective approximation errors. Therefore, designing an optical system for Intel's 4nm node in Fusion360would be a somewhat too optimistic idea.

 

Consider checking:

https://forums.autodesk.com/t5/fusion-360-design-validate/ellipse-perimeter-length/m-p/11387597

 

Also, look at some visuals of a practical exercise of designing truly trochoidal elliptical gears, where σ ~ 10⁻⁸ has shown up. The description of its details would be too long and too cumbersome for me … and you. I only say that achieving perfect trochoidal rotation of two identical elliptical pinion-gear pairs is impossible. However, such close-to-perfect synchronized movement is possible … but only after very subtle modification of ellipsoidal shapes (in the middle of the video frame). One can achieve accurate trochoidal rotation by introducing a slight shape-asymmetry in pinion-gear pair (Ell_D), although in both cases they look like ellipses, don't they?

NonCircular_arcd.jpg

 NonCircular_mono.jpg

 

Attached files:

NonCircular_mono.jpg   4K_mono    (0.3MB)  https://a360.co/3sb5Qpw 

NonCircular_mono.mp4   4K_mono    ( 54MB)  https://a360.co/3MnNmZM 

NonCircular_arcd.jpg   4K_stereo  (0.4MB)  https://a360.co/479yZQz 

NonCircular_arcd.mp4   4K_stereo  (105MB)  https://a360.co/3MlMsNe 

 

To be viewed on 4K media devices (monitors, UHD TVs, projectors...) of reasonable performance. For the best experience, use stand-alone media applications (WMP, VLC) and the native resolution 3840x2160 - full screen. The '_arcd' files require an anaglyph red/cyan glasses, while '_al' is for active shutter glasses 3D hardware (~30 deg viewing angle is recommended). Download the files over a network, where the cost of doing so is not a concern. The files are to be used for private, non-commercial purposes only.

 

Regards

MichaelT

MichaelT
Message 7 of 16

GRSnyder
Collaborator
Collaborator

@edgemarston wrote: I tried finding an easy algebraic explanation for how this works and had trouble.

To follow up more directly on @MichaelT_123's comments, it doesn't work. It's an approximation. Which may be perfectly fine for your application!

 

Fusion 360's modeling engine uses NURBS--nonuniform rational B-splines--to represent splines and arbitrarily curved surfaces. The "rational" part means that control points can have weights attached to them. Conic sections can only be exactly represented by rational NURBS.

 

Fusion 360's UI does not deal with rationality (or nonuniformity) at all. I'm tempted to say "unfortunately," but it's not really unfortunate; it's a design choice, and probably the right one. These refinements are hard to represent in a UI.

 

The bottom line is that you can't construct a rational spline (and hence, an accurate spline representation of an ellipse) in the UI. You can, with a short script, convert other sketch curves to rational NURBS curves, but they show up as "fixed splines" which do not display their control points and can't be edited. 

Message 8 of 16

jeffescott
Advisor
Advisor

Definitely gonna help me.  It will allow half an ellipse to be parametrized.   I use a lot of 1/2 ellipses 

0 Likes
Message 9 of 16

MichaelT_123
Advisor
Advisor

Hi Mr. JScottSWZG.


There is SketchEllipticalArc function at API level. If you like only half of the ellipses (quite a rare phenomenon, although for descendants of the Duke of Buccleuch, it could be understandable), consider banging on TF360 doors to expose it in UI. It will be parametric, more intuitive and cleaner looking in your sketches.


Regards
MichaelT

 

MichaelT
0 Likes
Message 10 of 16

jeffescott
Advisor
Advisor

Sweet

0 Likes
Message 11 of 16

jeffescott
Advisor
Advisor

How do I bang on Tf 360 door?

Message 12 of 16

MichaelT_123
Advisor
Advisor

Hard!

MichaelT
Message 13 of 16

Drewpan
Advisor
Advisor

Hi,

 

Ok. I give up. What is the reference for:

 

If you like only half of the ellipses (quite a rare phenomenon, although for descendants of the Duke of Buccleuch, it could be understandable)

 

all about?

 

I have looked but the closest I have found is 4 Crescents in the 3rd Dukes Coat of Arms,

Drewpan_0-1698727037542.png

 

and I'm not sure if its about The Great Gatsby.

Drewpan_1-1698727152071.jpeg

 

 

Cheers

 

Andrew😎

Message 14 of 16

GRSnyder
Collaborator
Collaborator

@MichaelT_123 wrote: There is SketchEllipticalArc function at API level...consider banging on TF360 doors to expose it in UI. It will be parametric, more intuitive and cleaner looking in your sketches.

It's exposed, it's exposed. You shall have all the elliptical arcs you desire. It is my gift.

 

If you Trim an ellipse, the remaining fragment is a SketchEllipticalArc. The original a and b are not retained, so there are always multiple possible ellipses that connect any two given elliptical arc endpoints. Unfortunately, the sketch solver doesn't seem to be very good at distinguishing among them. I would have expected that, e.g., you could specify one or more additional fixed points along the curve to disambiguate, but that doesn't seem to work.

 

Admittedly, this is not the same as being able to specify an elliptical arc in some kind of structured fashion.

 

0 Likes
Message 15 of 16

MichaelT_123
Advisor
Advisor

 Hi Fellows,

I put some effort into verifying some claims I made in my previous post. In essence, I modified/extended the sample API script, adding a few lines of code drawing a SketchEllipticalArc. Look at the comments and investigate my slight modifications, allowing parametrization of the curve.

Play vigorously with these new toys … and find their weak points.

Adding SketchEllipticalArc to UI is possible … and should be as easy and mindless as our morning routines. I hope TF360 will be willing to sit and deliver on the task.

EllipseArch_Script.png

 

# Author: Autodesk
# Modified: MicheltT_123
# Dat: 31 Oct 2023

import adsk.core, adsk.fusion, traceback
from math import pi as π

def run(context):
    ui = None
    try: 
        app = adsk.core.Application.get()
        ui = app.userInterface

        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        design = app.activeProduct

        # Get the root component of the active design.
        rootComp = design.rootComponent

        # Create a new sketch on the xy plane.
        sketches = rootComp.sketches
        xyPlane = rootComp.xYConstructionPlane
        sketch = sketches.add(xyPlane)

        if False:
            # Draw two connected lines.
            lines = sketch.sketchCurves.sketchLines
            line1 = lines.addByTwoPoints(adsk.core.Point3D.create(0, 0, 0), adsk.core.Point3D.create(3, 1, 0))
            line2 = lines.addByTwoPoints(line1.endSketchPoint, adsk.core.Point3D.create(1, 4, 0))

        if False:
            # Draw a rectangle by two points.
            recLines = lines.addTwoPointRectangle(adsk.core.Point3D.create(4, 0, 0), adsk.core.Point3D.create(7, 2, 0))
        if False:
            # Use the returned lines to add some constraints.
            sketch.geometricConstraints.addHorizontal(recLines.item(0))
            sketch.geometricConstraints.addHorizontal(recLines.item(2))
            sketch.geometricConstraints.addVertical(recLines.item(1))
            sketch.geometricConstraints.addVertical(recLines.item(3))
            sketch.sketchDimensions.addDistanceDimension(recLines.item(0).startSketchPoint, recLines.item(0).endSketchPoint,
                                                        adsk.fusion.DimensionOrientations.HorizontalDimensionOrientation,
                                                        adsk.core.Point3D.create(5.5, -1, 0))
        if False:
            # Draw a rectangle by three points.
            recLines = lines.addThreePointRectangle(adsk.core.Point3D.create(8, 0, 0), adsk.core.Point3D.create(11, 1, 0), adsk.core.Point3D.create(9, 3, 0))
        if False:
            # Draw a rectangle by a center point.
            recLines = lines.addCenterPointRectangle(adsk.core.Point3D.create(14, 3, 0), adsk.core.Point3D.create(16, 4, 0))
        if True:
            # Draw sketchEllipticalArc
            centerPoint   = adsk.core.Point3D.create(0, 0, 0)
            majorAxis     = adsk.core.Vector3D.create(8, 0, 0)
            minorAxis     = adsk.core.Vector3D.create(0, 4, 0)
            startAngle    = 0.0
            sweepAngle    = π/4
            ellipticalArc = sketch.sketchCurves.sketchEllipticalArcs.addByAngle(centerPoint, majorAxis, minorAxis, startAngle, sweepAngle)
            # TODO by YOU
            # ellipticalArc = sketch.sketchCurves.sketchEllipticalArcs.addByEndPoints(centerPoint, majorAxis, minorAxis, startPoint, endPoint)
        

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 Regards

MichaelT

MichaelT
Message 16 of 16

27Fusion2
Contributor
Contributor

Thank you for posting! Found this hugely helpful. Been looking for exactly such a solution (I've found the ellipse sketch object in Fusion to be extremely buggy in attempting to satisfy tangent constraints). I'm surprised how simple the math is. Curious about the .935 constant...

0 Likes