Jump to content

Recommended Posts

Posted

I'm using the following code to construct a polyline. It works but I was hoping that somewhere in AutoCAD there is a method for smoothing this curve out.

(defun c:bglarc (/)

  (setq a01 '(587.41129714 -1894.27598824)
	a02 '(513.49131818 -1895.98376109)
	a03 '(439.73430182 -1901.19365819)
	a04 '(366.29910442 -1909.90662304)
	a05 '(293.37692934 -1922.08362964)
	a06 '(221.38947498 -1938.71177195)
	a07 '(157.38596545 -1974.94950554)
	a08 '(105.59755857 -2042.51866343)
	a09 '(91.77147163 -2102.01021408)
	a10 '(98.17808010 -2173.26242179)
	)
  
  (command-s "._PLINE"
    a01
    a02
    a03
    a04
    a05
    a06
    a07
    a08
    a09
    a10
    ""
    )

  (reset)
  (princ)
  )

 

Posted

You want a least squares fit arc which attempts to give best answer, I think CIV3D has it, I know for lines.

 

Yep

image.png.08b1018af6f78fc5699c951f411956e8.png

  • Like 1
Posted

Whereas the method by "least squares" will give the rigorous mathematical result, I prefer the method by "least effort".

 

Having drawn the polyline, I would then go to PEDIT and curve fit by the FIT option. This makes the curve go through all the base points.

 

 

Curve by least effort.PNG

  • Like 1
Posted

Using PEDIT and FIT will convert the polyline to a series of arcs.  Two arcs are created between each polyline vertex.  The arc tangent will be the same where  two arcs  meet.  That is, the curve will have a continuous its first derivative throughout its length.   The result may deviate from the original polyline by quite a bit..  You may get a smoother result by using SPLINE and the FIT method specifying each of the 10 points for the spline's fit points.  This will yield a spline with a continuous first and second second derivative,  That is, a smooth function for the change in the change in slope as well as just the slope. By default, the curve between each of the points will be a cubic.

 

The red curve below is the result of using pedit on the white polyline and the green curve is a spline.

image.thumb.png.0f20a3602da3b13703f61ab2e4871532.png

Posted

However, if you want a spline, then you should draw a spline in the first place and you will have to define the start and finish tangents.

 

Whatever you do, DO NOT Spline fit in PEDIT. If you do, the line will NOT pass through your points.

Posted

Sorry, but my previous attempts to post had problems. I found that by simply changing the command from PLINE to SPLINE it works as predicted. Thanks for all the replies. Geometry was never my strong suit.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...