1. ## average coordinates

Registered forum members do not see this ad.

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???

2. Code:
```(defun average ( lst )
(mapcar '(lambda ( x ) (/ x (length lst))) (apply 'mapcar (cons '+ lst)))
)```
Code:
```(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)```

3. Originally Posted by amir0914
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

4. Registered forum members do not see this ad.

thank you marko_ribar, big up to you

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts