Author Topic: points up in two list of points  (Read 463 times)

0 Members and 1 Guest are viewing this topic.

dgpuertas

  • Newt
  • Posts: 47
points up in two list of points
« on: September 24, 2019, 01:02:31 PM »
I have two list of points

I need to obtain another list with the points up include intersection.



Two lisp, one is natural terrain and the other is new terrain, and i need to obtain the final terrain.


in the image you can see more clearly what I need



Thanks a lot and sorry about my english



Dlanor

  • Newt
  • Posts: 170
Re: points up in two list of points
« Reply #1 on: September 24, 2019, 08:05:11 PM »
How are you getting the lists?

If the lists were lwpolylines you could get a list of the intersection points between the two polylines using the intersectwith method. Then process each polyline drawing a vertical ray from each vertex and test if it intersects the other polyline. If it doesn't add that vertex to the intersection list. Repeat swapping the polylines should give you a list of all the upper points, then sort the list by the x-coord.
« Last Edit: September 24, 2019, 08:15:59 PM by Dlanor »

dgpuertas

  • Newt
  • Posts: 47
Re: points up in two list of points
« Reply #2 on: September 25, 2019, 04:04:54 AM »
There is not polylines its list of 2D points.

(setq ls1 (list (list 0. 34.)(list 40. 34.34)(list 50. 30.3).........)

and both begin in x= 0.0 ang finish in the same x numer.

I can create polylines but for time procesing i prefer not.

I ask for anyone have similar code to modify.

Thans Dlanor for your post

BIGAL

  • Bull Frog
  • Posts: 317
  • 30 + years of using Autocad
Re: points up in two list of points
« Reply #3 on: September 25, 2019, 11:15:44 PM »
Creating plines then do something then erase them is not a problem using the built in intersectwith function saves programming look again at Dlanor idea.

This is civil design software solution have you looked at that ?
A man who never made a mistake never made anything

dgpuertas

  • Newt
  • Posts: 47
Re: points up in two list of points
« Reply #4 on: September 26, 2019, 04:19:53 AM »
I use AutoCAD only.

I know that Civil 3D or similar can do it (i hope) but I will use at 1% of possibilities and think that is a few use to buy the software.

I try do it by myself.

Thans a lot


Dlanor

  • Newt
  • Posts: 170
Re: points up in two list of points
« Reply #5 on: September 26, 2019, 05:50:27 AM »
There is not polylines its list of 2D points.

How do you get the lists of 2D points? Do you write them using the keyboard? Are they imported from other software?

dgpuertas

  • Newt
  • Posts: 47
Re: points up in two list of points
« Reply #6 on: September 27, 2019, 03:44:09 AM »
-one list is the prolife of a line from one TIN (3dFace)
Thanks a lot YMG
http://www.theswamp.org/index.php?topic=9042.msg555712#msg555712

-the other list its calculate by another lisp that find terrain to aport.

dgpuertas

  • Newt
  • Posts: 47
Re: points up in two list of points
« Reply #7 on: October 02, 2019, 12:42:42 PM »
I finally did it.


And run with three parametres two list and a fun
fun is <  Find the point at bottom
fun is > Find the point at top



Code: [Select]
;(junta_lista_puntos_terreno_arriba_abajo (list (list 0 2) (list 5 2) (list 10 1) (list 20 3)) (list (list 0 3) (list 4 0) (list 11 2) (list 22 3.4)) <)

(defun junta_lista_puntos_terreno_arriba_abajo (listerr lisapp fun / list_inter ls1 ls2)

  (setq list_inter (apply (function append) (mapcar (function (lambda (p1 p2)
       (vl-remove nil (mapcar (function (lambda (p3 p4)
  (inters p1 p2 p3 p4))) lisapp (cdr lisapp))))) listerr (cdr listerr)))
ls1 (vl-remove nil (mapcar (function (lambda (p / y)
(if (setq y (BUSCA_Y_PERFIL (car p) lisapp))
    (if (fun (cadr p) y) p) p))) listerr))
ls2 (vl-remove nil (mapcar (function (lambda (p / y)
(if (setq y (BUSCA_Y_PERFIL (car p) listerr))
  (if (fun (cadr p) y) p) p))) lisapp))
)
 
  (vl-sort (append list_inter ls1 ls2) (function (lambda (a b) (< (car a) (car b)))))
)


roy_043

  • Water Moccasin
  • Posts: 1720
  • BricsCAD 18
Re: points up in two list of points
« Reply #8 on: October 02, 2019, 01:38:07 PM »
Can't test the code because BUSCA_Y_PERFIL is missing.
It is a nice start, but just reading the code I believe it will only work in certain quite specific situations.
It will not handle the example in the image attached to your first post for example.

dgpuertas

  • Newt
  • Posts: 47
Re: points up in two list of points
« Reply #9 on: October 02, 2019, 04:50:35 PM »
works fine,

BuscaYperfil ->

find the cartesian y value with x position and a list of points.
linear interpolation between the point ahead and the behind

use another function like linear interpolation and find integer item inside a list of points

If you are interested i will post them

Lee Mac

  • Seagull
  • Posts: 12267
  • London, England
Re: points up in two list of points
« Reply #10 on: October 02, 2019, 05:04:06 PM »
Any algorithm which involves sorting the points will fail for concave terrain, for example, consider the result you will obtain for the following two polylines when sorting by x-coordinate:

Code: [Select]
(entmake
   '(
        (0 . "LWPOLYLINE")
        (100 . "AcDbEntity")
        (100 . "AcDbPolyline")
        (90 . 10)
        (70 . 0)
        (10 0.0 0.0)
        (10 2.5 0.0)
        (10 1.5 0.5)
        (10 1.0 1.5)
        (10 1.5 2.5)
        (10 2.5 3.0)
        (10 3.5 2.5)
        (10 4.0 1.5)
        (10 3.5 0.5)
        (10 5.5 0.5)
    )
)
(entmake
   '(
        (0 . "LWPOLYLINE")
        (100 . "AcDbEntity")
        (100 . "AcDbPolyline")
        (90 . 4)
        (70 . 0)
        (10 0.0 0.5)
        (10 2.5 0.5)
        (10 3.5 1.0)
        (10 5.5 1.0)
    )
)

The correct result would be:
Code: [Select]
(entmake
   '(
        (0 . "LWPOLYLINE")
        (100 . "AcDbEntity")
        (100 . "AcDbPolyline")
        (90 . 9)
        (70 . 0)
        (43 . 0.1)
        (10 0.0 0.5)
        (10 1.5 0.5)
        (10 1.0 1.5)
        (10 1.5 2.5)
        (10 2.5 3.0)
        (10 3.5 2.5)
        (10 4.0 1.5)
        (10 3.75 1.0)
        (10 5.5 1.0)
    )
)

But this cannot be achieved when sorting by either coordinate.

roy_043

  • Water Moccasin
  • Posts: 1720
  • BricsCAD 18
Re: points up in two list of points
« Reply #11 on: October 02, 2019, 07:35:13 PM »
works fine,
My apologies, I see now that I have misread the code.

dgpuertas

  • Newt
  • Posts: 47
Re: points up in two list of points
« Reply #12 on: October 03, 2019, 02:49:03 PM »

Lee as usual is right

The point is that situation is not real because the TIN terrain never consider concave terrain. (in my opinion)
For me is correct and i use well.

roy_043, its not necesary apologies....

I rewrite because double if its not necesary.

Code: [Select]
(defun junta_lista_puntos_terreno_arriba_abajo (listerr lisapp fun / list_inter ls1 ls2)

  (setq list_inter (apply (function append) (mapcar (function (lambda (p1 p2)
       (vl-remove nil (mapcar (function (lambda (p3 p4)
  (inters p1 p2 p3 p4))) lisapp (cdr lisapp))))) listerr (cdr listerr)))
ls1 (vl-remove nil (mapcar (function (lambda (p / y)
(if (or (null (setq y (BUSCA_Y_PERFIL (car p) lisapp))) (fun (cadr p) y)) p)
    )) listerr))
ls2 (vl-remove nil (mapcar (function (lambda (p / y)
(if (or (null (setq y (BUSCA_Y_PERFIL (car p) listerr))) (fun (cadr p) y)) p)
    )) lisapp))
)
 
  (vl-sort (append list_inter ls1 ls2) (function (lambda (a b) (< (car a) (car b)))))
)