Getting all the listed points within a window

Discussion in 'AutoCAD' started by RaghuMN, Aug 19, 2004.

  1. RaghuMN

    RaghuMN Guest

    Hi all,

    I have 1000's of points stored in a LIST and 100's of windows (rectangles). These are not physical points, but coordinates listed in a list.

    For each window, with the known 2 diagonally opposite corner points, how can I find the points that lie within the window?

    One way is to go to each point in the list and find it's location w.r.t the window as:
    (and
    (>= (car pt) (car pt1))
    (>= (cadr pt) (cadr pt1))
    (<= (car pt) (car pt2))
    (<= (cadr pt) (cadr pt2))
    )
    where pt is the point coordinates, pt1 and pt2 are window corner points.

    This may be very time consuming for checking 100 windows w.r.t 1000 points, for which there is 1000 x 100 combinations.

    Are there any other methods that can trap all the points that fall into a window at once?

    Any help much appreciated.

    Thanks,

    MNRaghu
     
    RaghuMN, Aug 19, 2004
    #1
  2. RaghuMN

    zeha Guest

    NRaghu,

    Maybe this is what you mean


    (defun PtsLowerLeftUpperRight ( ll ur pts)

    (vl-remove-if-not '(lambda(x)(and (<= (car ll)(car x)(car ur))(<= (cadr ll)(cadr x)(cadr ur)))) pts)

    )

    (PtsLowerLeftUpperRight '(0 0 0) '(1000 1000 0) '((-100 100 0)(0 0 0)(900 900 0)(1000 1000)(100 100)(2000 2000 0)))

    ;;give ---> ((0 0 0) (900 900 0) (1000 1000) (100 100))


    Cheers

    Harrie
     
    zeha, Aug 19, 2004
    #2
  3. RaghuMN

    Joe Burke Guest

    This might help.

    ;by Tony Tanzillo - returns LL and UR corners of a point list
    (defun extents (plist)
    (list
    (apply 'mapcar (cons 'min plist))
    (apply 'mapcar (cons 'max plist))
    )
    )

    Joe Burke


    are not physical points, but coordinates listed in a list.
    the points that lie within the window?
    which there is 1000 x 100 combinations.
     
    Joe Burke, Aug 19, 2004
    #3
  4. RaghuMN

    RaghuMN Guest

    Zeha,

    You are correct. You have given me what I needed.
    Thanks a lot for the assistance.

    MNRaghu
     
    RaghuMN, Aug 20, 2004
    #4
  5. RaghuMN

    RaghuMN Guest

    Joe,

    Thanks for getting me another method of finding the extent corners of a window.

    MNRaghu
     
    RaghuMN, Aug 20, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.