Author Topic: splines with second degree curve data degrade?  (Read 9012 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
splines with second degree curve data degrade?
« on: December 15, 2011, 01:52:17 PM »
Hi there, recently I revised my old hyperbola.lsp & parabola.lsp and now I've found that CAD degrade SPLINE with data for second degree curve. I've used this Stefan's PDF that can be found here :
http://www.theswamp.org/index.php?topic=40003.0.msg452900#msg452900
Please, check my *.dwg where I've created 2 parabola SPLINE curves, one with curve extension level = 0, and other one with level = 10. I've used inverse construction method for obtain extension level endpoints... So, for parabola there are no formula calculations inside routine (only construction method), but that is why I've noticed this lack of SPLINE representation. I've checked parameters of start, mid, end points and they are for both splines 0.0, 0.5, 1.0... Maybe this is why representation isn't as expected for parabola with extension level 10 (start and end points are far away distant and parameters of curve near middle point are much the same almost 0.5 exactly, as for one with level 0, near middle point parameters vary more...

So here are codes for parabolas and hyperbolas :
http://www.theswamp.org/index.php?topic=48929.msg540574#msg540574

So am I wright if I conclude that after all it's better to use SPLINES with more points segmentation obtained using formulas for 2nd degree curves like parabola & hyperbola, than SPLINES with data for drawing 2nd degree curves with end points, central control vertex with its weight?

M.R.
:???:
« Last Edit: February 24, 2015, 11:59:30 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #1 on: December 16, 2011, 02:56:11 AM »
Hi Marko

The parabola in your drawing is just fine. I think it looks sharp because of  approximation made by AutoCAD. Try to draw an Ellipse over it and you’ll see the same representation.
Take a look here (scroll down to Special Cases) http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ffa23ce210c4a30acaf-6f01.htm.
It says “You can create a spline with a parabolic shape by specifying a degree 2 spline created with exactly 3 control vertices”.  So you don’t need more control points for an exact representation, but it can be done, if you wish. See attached dwg.

ps. Sorry for not answering in the other thread, even if I promised... Glad that my .pdf helped.

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #2 on: December 16, 2011, 03:01:04 AM »
I think the degradation is related to the inaccuracies of floating point math operations at those scales.  A “Point at Parameter” operation would typically require a math operation that squares numbers – thus amplifying the issue.

Even though you file gives an excellent visual representation of the problem, the actual percentage of error is still quite small.  I would be surprised if any elevated point count spline could match the accuracy level, given the scale shown.
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #3 on: December 16, 2011, 04:47:32 AM »
Stefan, I saw your examples on the right showing parabolas with refined control vertexes... So I just refined with splinedit main CV with weight 1.0 to 2 new control vertexes and parabolas matches (level = 0 equal level = 10)... But now I don't know what shell we do with your ellipse? Using A2008, so I can't explode it to spline... Maybe that's just what it needs to be exploded into spline. Check my *.dwg now...

Sorry, for posting wrong *.dwg, it seems that after saving CAD didn't represented spline as it did just after splinedit - refine... So all I could do is splinedit from A2011 - A2012 and convert it to polyline with precision 99. Results are approximately correct... Still I don't know how you even draw that ellipse, but I read somewhere on www that if you draw it with variable PELLIPSE set to 1, you can draw it as polyline, and another method is to save dwg as DXF R 12 and after do DXFIN you'll get 3dpolyline from your ellipse, but I've tried this and I think that approximation is bad and for ellipse and for spline-parabola, and the third method is to offset ellipse for some amount and then offset it back - ellipse will be converted into spline (I offset your ellipse by 1.0 inside, splinedit -> polyline precision 13, and offset new polyline by 1.0 outside)... So in the end I'll post what I did best to simulate approximation of representation of extension level = 10 spline-parabola and approximation for your ellipse...

M.R.
« Last Edit: December 16, 2011, 07:18:13 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #4 on: December 16, 2011, 06:39:21 AM »
...But now I don't know what shell we do with your ellipse?...
I drew the ellipse just to show you that is nothing wrong with your parabola. It appear sharp just like some other objects (ellipse in my sample) when its geometry is near to a degenerate geometry. When the opening of parabola is decreasing to zero, it becomes a line; so an ellipse, when its minor radius tends to zero.

I do not understand what you are trying to do with that parabola? Maybe you can explain better so we can find another solution.


ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #5 on: December 16, 2011, 06:48:37 AM »
Stefan, watch for my uploaded *.dwg and you'll see how big differences are between original splines, ellipses with newly created polylines from them...

I only wanted to show that CAD representation could be better even with so distant and degenerated objects, I thought that original entities would be presented more accurate than ones that are produced from them (thought that CAD will operate without limits at least for presentation purposes)...

M.R.
:)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #6 on: December 16, 2011, 07:37:15 AM »
I only wanted to show that CAD representation could be better even with so distant and degenerated objects....

So it's just a representation issue... In this case, do you really need so long parabola? It is miles away from the picked points.
I would limit the value of x or y, depending on the opening of parabola.

If is a narrowed one, chose an x not larger then, say, 5 times the width of screen.
For a wider opening you could limit the y value.

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #7 on: December 16, 2011, 07:43:48 AM »
When the opening of parabola is decreasing to zero, it becomes a line...

Opening of parabola is never going to be decreased to zero; their openings goes to infinity and closing never happens; that means also and for hyperbola, opening end points are tending to be closer to their corresponding asymptote, but end points never touches them no matter how big is branch of hyperbola... That is pure geometry analyses... And analyzing conic sections you can see that circle is stretched to ellipse, it is stretched so deep that ellipses brakes and first brake is parabola (other end point of ellipse went to infinity), end points of parabola are now end points of minor ellipses radius, after that parabola is stretched and it firstly becomes hyperbola with asymptotes almost parallel to each other and main axis of hyperbola, and then asymptotes tend to make acute angle, hyperbola is stretched even more, all to the point that asymptotes become one orthogonal axis to main axis of hyperbola and hyperbola becomes that single xline - asymptote... So only the end of stretch is closure infinity - xline of asymptote and it is orthogonal to main axis of stretching original circle as first special case of conic section... If stretching of circle is inside circle transforms to ellipse witch in the end degenerates to line that is orthogonal to axis of stretching...

Explanation of infinity stretching of main circle as first special case of conic section (cone+plane with normal = normal of cone) by M.R.

:)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: splines with second degree curve data degrade?
« Reply #8 on: December 16, 2011, 08:35:07 AM »
When the opening of parabola is decreasing to zero, it becomes a line...

Opening of parabola is never going to be decreased to zero; their openings goes to infinity and closing never happens; that means also and for hyperbola, opening end points are tending to be closer to their corresponding asymptote, but end points never touches them no matter how big is branch of hyperbola... That is pure geometry analyses... And analyzing conic sections you can see that circle is stretched to ellipse, it is stretched so deep that ellipses brakes and first brake is parabola (other end point of ellipse went to infinity), end points of parabola are now end points of minor ellipses radius, after that parabola is stretched and it firstly becomes hyperbola with asymptotes almost parallel to each other and main axis of hyperbola, and then asymptotes tend to make acute angle, hyperbola is stretched even more, all to the point that asymptotes become one orthogonal axis to main axis of hyperbola and hyperbola becomes that single xline - asymptote... So only the end of stretch is closure infinity - xline of asymptote and it is orthogonal to main axis of stretching original circle as first special case of conic section... If stretching of circle is inside circle transforms to ellipse witch in the end degenerates to line that is orthogonal to axis of stretching...

Explanation of infinity stretching of main circle as first special case of conic section (cone+plane with normal = normal of cone) by M.R.

:)
Very good explanations but you consider a fixed cone generator. If you start to narrow that cone then a parabola (or hyperbola) opening could tend to zero.

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #9 on: December 16, 2011, 09:07:48 AM »
Very good explanations but you consider a fixed cone generator. If you start to narrow that cone then a parabola (or hyperbola) opening could tend to zero.

That's true, but in my case I draw parabola that has mathematically saying quadratic coefficient y=kx^2, witch means that k/=0, k/=~, => y/=0, y/=~; where ~ is infinity, and -~<x<~, so my parabola is never going to tend to close to zero... Even if that's supposed to happen, that is no real reason that CAD represent parabola near apex curvature with approximation to line, but to quadratic 2nd degree curvature like my example with extension level 0...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #10 on: December 16, 2011, 05:07:59 PM »
In you first post I thought you were referring to AutoCAD’s inability to return an accurate MID osnap for the longer parabola.  I do believe that is related to the floating point issue I mentioned. 

See the attached – it has a similarly scaled parabola. 

The Properties Panel shows the two upper CPs symmetrically positioned either side of the lower point.  Still, AutoCAD does not give an accurate MID snap.

With regard to the faceted representation:  It seems that AutoCAD uses some running optimization unless forced into more accuracy.  With the attached file, draw a line from the point to the spline while invoking the TAN osnap.

The first thing we see is that the line snaps to the appropriate (perhaps mildly inaccurate) position, not on the more linear representation.  The interesting thing is that now a REGEN forces the spline to the proper curved path.  At least it does in AutoCAD 2012.  See the attached PDFs showing a before and after.
« Last Edit: December 24, 2011, 03:38:26 AM by SEANT »
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #11 on: December 17, 2011, 06:25:08 AM »
SEANT, at first glance I thought you solved the problem (genial idea), but it works only for parabola... Now it happens that the real issue is an ellipse... Look to my *.dwg (I've tried the same - tan snap with ellipse - no success!!!)

M.R.
 :|
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #12 on: December 17, 2011, 07:20:12 AM »
I believe AutoCAD treats an ELLIPSE as a hybrid object, i.e., the behind the scenes calculations use a NURB curve, but the ELLIPSE entity implements its own methods for REGENs and such.

For display purposes, you could recreate the ellipse via a degree 2 spline to get the same performance we saw with the parabola (see attached).  As a matter of fact, I originally intended to include that with my previous file.  Unfortunately, AutoCAD 2012 has a bug with regard to rational NURB curves, so the entity is not very reliable for subsequent GRIP edit operations.

http://forums.autodesk.com/t5/Drafting-Techniques/Bug-using-splines/td-p/3138850

I would not recommend its use for anything more than temporary display work.
Sean Tessier
AutoCAD 2016 Mechanical

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: splines with second degree curve data degrade?
« Reply #13 on: December 17, 2011, 10:13:55 AM »
You are genius SEANT... You just didn't mentioned that CV for quarter ellipse main tangents must have weight (sqrt 2)/2.0

M.R.
Thank you all for reply...
 :wink:
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

SEANT

  • Bull Frog
  • Posts: 345
Re: splines with second degree curve data degrade?
« Reply #14 on: December 17, 2011, 10:55:37 AM »
... You just didn't mentioned that CV for quarter ellipse main tangents must have weight (sqrt 2)/2.0 . . . .

Oh yeah.  Sorry, I forgot to make note of that.
Sean Tessier
AutoCAD 2016 Mechanical