+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Location
    Australia
    Posts
    30

    Default 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. #2
    Super Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2014
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    1,290

    Default

    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)

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  3. #3
    Senior Member satishrajdev's Avatar
    Computer Details
    satishrajdev's Computer Details
    Operating System:
    Windows 7 - 64bit
    Computer:
    DELL
    RAM:
    8 GB
    Primary Storage:
    500 GB
    Monitor:
    DELL
    Discipline
    Surveying
    satishrajdev's Discipline Details
    Occupation
    CAD Engineer
    Discipline
    Surveying
    Details
    Design Survey Utilities (i.e. Bathymetry & Geophysical Survey) Design of Survey Planning. Preparation of Alignment Sheets. Programming in AutoCAD.
    Using
    AutoCAD 2014
    Join Date
    Apr 2012
    Location
    Aamchi Mumbai, India
    Posts
    451

    Default

    Quote Originally Posted by amir0914 View Post
    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
    Best Regards,
    Satish Rajdev

    If you ride like there is no tomorrow... Don't worry, there won't be !!!!
    www.facebook.com/satish.rajdev

  4. #4
    Full Member
    Using
    AutoCAD 2016
    Join Date
    Feb 2016
    Location
    Australia
    Posts
    30

    Default

    Registered forum members do not see this ad.

    thank you marko_ribar, big up to you

Similar Threads

  1. average time for drawings
    By michaelbergen in forum AutoCAD Beginners' Area
    Replies: 16
    Last Post: 26th Dec 2013, 08:17 pm
  2. Average Website Visitors/Day
    By good_m in forum Web Design
    Replies: 14
    Last Post: 25th Apr 2012, 10:31 am
  3. Average, Min, Max
    By johnengineer in forum AutoLISP, Visual LISP & DCL
    Replies: 24
    Last Post: 23rd Dec 2008, 01:11 pm
  4. Average, Min, Max
    By johnengineer in forum AutoCAD Beginners' Area
    Replies: 8
    Last Post: 18th Dec 2008, 06:30 am
  5. Average Text code. But it not fine, Help
    By Nad SK in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 8th Oct 2007, 10:12 am

Bookmarks

Posting Permissions

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