lamensterms Posted yesterday at 02:29 PM Posted yesterday at 02:29 PM Hey, I've got a project that requires me to reproduce/trace a 3D spline, with ARC segments. The goal being to reproduce the SPLINE as accurately as possible, with as few ARCs as possible Just hoping to get some thoughts on methods to approach this challenge. Right now my method is to divide the SPLINE into sections based on the local normal-ness of part of the SPLINE. Just visually trying to fit each ARC to a portion of the SPLINE I have to perform this task 8 times for this project so hoping to come up with a neat and robust method DWG attached - in this example I am trying to work to a limit of 5 ARCs TEMP.dwg Quote
CyberAngel Posted 2 hours ago Posted 2 hours ago Obviously, you can't use the original spline or you'd be doing that. It might help us to know why, though. I assume the goal is a 2D spline. Have you thought about starting with an actual spline? That way you can adjust the control points and their tangents, instead of using polyline arcs, which seems more complicated. If the goal is a 2D polyline, you can still draw it with a spline and then convert it to a polyline with SPLINEDIT. The more we know about your project, the better we can help. Right now I'm just guessing. Quote
lamensterms Posted 1 hour ago Author Posted 1 hour ago Hey thanks for the reply The reason to convert to a small quantity of ARCs is because the SPLINE will become fabricated out of steel pipe. Fab method requires the shape to be fabricated from curved pipe segments. Unfortunately for this project, corkscrew/spiral pipe segments are not an option, so we are stuck with ARCs Quote
lrm Posted 1 hour ago Posted 1 hour ago As I understand your question your goal is to approximate a 3D spline as a series of arcs (2d of course) that are positioned in series. To get a feel for the 3D nature and curvature of the spline I suggest first running my splinecurvature LISP program on the spline. Respond Y to the prompt: Do you want radius-of-curvature instead of curvature? [y/n] <n>: y and you will get a result like the following: The red lines are created at 100 points along the spline. They show the instantaneous radius of curvature of the spline at the points. The ends of the red lines are at the locations of the center of an arc that would duplicate the spline's curvature for a specific point on the spline. With this information you need to choose, starting at one end of the spline, 3 points along the spline that are in a generally "flat" area. Define a UCS for the 3 points then add an arc via the three point method. Repeat the process for the next "flat" section. Here are the results for two arcs. (defun C:SplineCurvatue (/ path inc n osm par der1 der2 curva p perp normv p2 sf curveType ans) ; = Degree Of Curvature - Lines ; Creates curvature lines or radius-of-curvature lines ; normal to a spline. ; LRM 8/18/2022 edited to place curvature vectors outside (setq path (car (entsel)) inc (/ (vlax-curve-getEndParam path) 100) n 0 osm (getvar 'osmode) ) (setvar 'osmode 0) (setvar "cmdecho" 0) (initget "y n") (setq ans (getkword "Do you want radius-of-curvature instead of curvature? [y/n] <n>: ")) (if (= ans "y") (setq curveType 1) (setq curveType 2 sf (getdist "Enter scale factor.") ) ) (repeat 100 (setq par (* inc n)) (setq der1 (vlax-curve-getfirstDeriv path par) der2 (vlax-curve-getSecondDeriv path par) ) ; calculate curvature at point par (setq d (distance '(0 0 0) (cross der1 der2))) (if (> (abs d) 1.0e-15) (progn (setq curva (/ (expt (distance '(0 0 0) der1) 3) d)) (if (= curveType 2) (setq curva (* -1. (* sf (/ 1. curva)))) ) (princ "\n") (princ n) (princ " curvature = ") (princ curva) (setq p (vlax-curve-getPointAtParam path par) perp (unitv (cross der1 (cross der2 der1))) normv (mapcar '* perp (list curva curva curva)) p2 (mapcar '+ p normv) ) (command "_.line" p p2 "") ) ; end progn ) (setq n (1+ n)) ) (setvar 'osmode osm) (setvar "cmdecho" 1) (princ) ) ;;; Compute the cross product of 2 vectors a and b (defun cross (a b / crs) (setq crs (list (- (* (nth 1 a) (nth 2 b)) (* (nth 1 b) (nth 2 a)) ) (- (* (nth 0 b) (nth 2 a)) (* (nth 0 a) (nth 2 b)) ) (- (* (nth 0 a) (nth 1 b)) (* (nth 0 b) (nth 1 a)) ) ) ;end list ) ;end setq c ) ;end cross (defun unitV ( v / d) (setq d (distance '(0 0 0) v) d (mapcar '/ v (list d d d)))) SplineCurvature.lsp Quote
lamensterms Posted 41 minutes ago Author Posted 41 minutes ago Wow nice that looks like a very interesting tool, thanks lrm Your understanding of my task is correct. And your suggested workflow is pretty much what I have been doing (except without your LISP of course), and I was using 3DFACE to allocate my 'flat' points. One of the biggest and time consuming challenges has been to determine which points I will use to fit the ARCs to, while also maximising fit accuracy and also smoothness of the transition to the next ARC. I think your routine will come on quite handy to help me decide where to finish 1 ARC and begin the next Thanks again for sharing! Quote
Recommended Posts
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.