GP_ Posted July 25, 2020 Share Posted July 25, 2020 (edited) Frequently, after a topographic survey, I have to prove the obtained area of a Lot of Land. This lisp creates a table with the analytical method of the Gauss's area formula. I do not need absolute precision, but logically (owing to rounding) by increasing decimal units you can get a result as close to the real one. It is still to be completed, but I never have time to finish it. You can change the nonsense I wrote in English AreaG.LSP Edited July 25, 2020 by GP_ 3 Quote Link to comment Share on other sites More sharing options...
GP_ Posted July 25, 2020 Author Share Posted July 25, 2020 Customization 3 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 26, 2020 Share Posted July 26, 2020 Wow! Astounding DCL work GP, very well done. Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted July 26, 2020 Share Posted July 26, 2020 Agree with Lee Mac. That DCL is amazing. Though capable, I've never written one this big. Quote Link to comment Share on other sites More sharing options...
GP_ Posted July 26, 2020 Author Share Posted July 26, 2020 @Lee @Jonathan Thanks Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted July 26, 2020 Share Posted July 26, 2020 I've run into this problem while inspired with this topic... To explain... According to math and lisp that implemented math, area of closed 2d spline should be equal to (vla-get-area) or (vlax-curve-getarea) or data from Properties panel... But routine gives approx. correct, but little less... I know that there is curving involved, but 100000 points is very dense, so there should be no bigger difference and by my testings - difference is seen at very first decimals - how can this be true? Can someone explain or elaborate or retest my research... (defun c:areaclosed2dspline ( / s spl n dx k pl ar ) (vl-load-com) (while (or (prompt "\nPick closed 2d spline in WCS...") (not (setq s (ssget "_+.:E:S" '((0 . "SPLINE"))))) (if s (or (not (vlax-curve-isclosed (ssname s 0))) (not (vl-every '(lambda ( x ) (equal (cadddr x) 0.0 1e-6)) (vl-remove-if-not '(lambda ( x ) (vl-position (car x) '(10 11))) (entget (ssname s 0))))) ) ) ) (prompt "\nMissed or picked spline not closed or picked spline not in WCS...") ) (setq spl (ssname s 0)) (initget 6) (setq n (getreal "\nSpecify precision segmentation <100000> : ")) (if (null n) (setq n 100000) (setq n (fix n)) ) (setq dx (/ (vlax-curve-getdistatparam spl (vlax-curve-getendparam spl)) n)) (setq k -1) (repeat n (setq pl (cons (vlax-curve-getpointatdist spl (* dx (setq k (1+ k)))) pl)) ) (setq pl (reverse pl)) (setq ar (abs (apply '+ (mapcar '(lambda ( a b ) (/ (- (* (car a) (cadr b)) (* (cadr a) (car b))) 2.0)) pl (append (cdr pl) (list (car pl))))))) (prompt "\nArea of closed 2d spline : ") (princ (rtos ar 2 20)) (princ) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted July 26, 2020 Share Posted July 26, 2020 Discard my post... I retested with another 2d spline and now routine returned little bigger result and difference was at 4th decimal, so it's accurate... Thanks for reading anyway... Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 26, 2020 Share Posted July 26, 2020 As you say there is the little bit of the arc segment area left out, unless there is a way of working out the approx radius between points on the spline the area will say always be a bit less. Spline like a "U" shape would be different again with + & - areas Quote Link to comment Share on other sites More sharing options...
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.