RepCad Posted July 10, 2018 Share Posted July 10, 2018 hi all, i'm beginner in autolisp and i need to a function to get average coordinates of a list coordinate, example : ((x1 y1 z1)(x2 y2 z2)(x3 y3 z3) , ..........) average : (x y) is it possible to do this without loop??? Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted July 10, 2018 Share Posted July 10, 2018 (defun average ( lst ) (mapcar '(lambda ( x ) (/ x (length lst))) (apply 'mapcar (cons '+ lst))) ) (average '((0.0 1.0 2.0 3.0) (1.0 2.0 3.0 4.0) (2.0 3.0 4.0 5.0) (3.0 4.0 5.0 6.0))) ;; => (1.5 2.5 3.5 4.5) 2 Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted July 10, 2018 Share Posted July 10, 2018 hi all, i'm beginner in autolisp and i need to a function to get average coordinates of a list coordinate, example : ((x1 y1 z1)(x2 y2 z2)(x3 y3 z3) , ..........) average : (x y) is it possible to do this without loop??? Are you trying to find our a centroid of coordinate list? If yes then try this http://www.lee-mac.com/polygoncentroid.html Quote Link to comment Share on other sites More sharing options...
RepCad Posted July 10, 2018 Author Share Posted July 10, 2018 thank you marko_ribar, big up to you 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.