Author Topic: Triangulation  (Read 12530 times)

0 Members and 1 Guest are viewing this topic.

Didge

  • Bull Frog
  • Posts: 211
Re: Triangulation
« Reply #30 on: February 15, 2006, 01:28:25 PM »
I think I've found the mathmatical formula I was looking for, namely the "Plane Equation":

http://www.ems-i.com/smshelp/Data_Module/Interpolation/Linear_Interpolationsms.htm

Many thanks to all those that assisted.
Think Slow......

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #31 on: February 15, 2006, 05:35:40 PM »
Didge,
Hope you share the (Get_Z) function when you get it working. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Didge

  • Bull Frog
  • Posts: 211
Re: Triangulation
« Reply #32 on: February 16, 2006, 07:40:49 AM »
Here's a snippet I've come up with to check the formula (its a command, not a function).
All seems ok with the interpolation, but I still need to add a check to ensure that the specified point is within the triangular boudary of the 3Dface.



;*********************************************************************
; GET-Z  -  Lisp command to interpolate Z elevations from a 3D face                           *
; =====     using the plane equation.                                                                   *
;                                                                                                                       *
;*********************************************************************
(defun c:GET-Z ( / ENT P1 P1 P3 X Y X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 A B C D Z)

         (setq ENT (car (entsel "\nSelect 3DFace ")))
         (setq P (getpoint "\nSelect location > "))

         (setq P1 (cdr (assoc 10 (entget ENT)))
                 P2 (cdr (assoc 11 (entget ENT)))
                 P3 (cdr (assoc 12 (entget ENT)))
         )
         (setq  X (car P)
                  Y (cadr P)
                 X1 (car P1)
                 Y1 (cadr P1)
                 Z1 (caddr P1)
                 X2 (car P2)
                 Y2 (cadr P2)
                 Z2 (caddr P2)
                 X3 (car P3)
                 Y3 (cadr P3)
                 Z3 (caddr P3)
         )
 
; Add check here to determine if the point (P) is within the triangular
; 3dface, if so process the following code.
 
         (setq A (+ (* Y1 (- Z2 Z3)) (* Y2 (- Z3 Z1)) (* Y3 (- Z1 Z2)) ))
         (setq B (+ (* Z1 (- X2 X3)) (* Z2 (- X3 X1)) (* Z3 (- X1 X2)) ))
         (setq C (+ (* X1 (- Y2 Y3)) (* X2 (- Y3 Y1)) (* X3 (- Y1 Y2)) ))
         (setq D (-  (- (* A X1)) (* B Y1) (* C Z1) ))
         (setq Z (-  (- (* (/ A C) X))  (* (/ B C) Y)  (/ D C)  ))
         (prompt (strcat "\nElevation= " (rtos Z 2 3) "              "))

  (princ)
)
Think Slow......

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #33 on: February 16, 2006, 08:47:40 AM »
Didge,
Nice work.

Here is a quickie that uses Doug Boards function to test for which side.
I wrapped it & modified the return value.

Code: [Select]
;;  return t if p is inside of 3 points
(defun inside (p p1 p2 p3 / sideof)

  ;;D. C. Broad, Jr.
  ;;(sideof <ray-origin> <another-point-on-ray> <point-to-be-tested>)
  (defun sideof (p1 p2 p / r)
    (setq r
           (cond
             ((equal p1 p 1e-10) 0)
             (t (sin (- (angle p1 p) (angle p1 p2))))
           )
    )
    (if (equal r 0 1e-10)
      0
      (if (minusp r) -1 1) ; CAB modified
    )
  )
  ;;return values
  ;;negative = point is to the right side of the ray
  ;;0 = point is on the ray
  ;;otherwise point is on the left side of the ray.
  ;;P1 should not equal P2 for meaningful results.

  (defun 2d (pt) (list (car pt) (cadr pt)))

  (setq p  (2d p)
        p1 (2d p1)
        p2 (2d p2)
        p3 (2d p3)
  )
  (= (sideof p1 p2 p) (sideof p2 p3 p) (sideof p3 p1 p))
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Didge

  • Bull Frog
  • Posts: 211
Re: Triangulation
« Reply #34 on: February 17, 2006, 05:30:45 AM »
That works like a dream, thanks CAB, and thanks to Doug Boards for sharing that function.

Just for the challenge, I was hoping to stick with pure mathematics using Ceva's theorem;

http://en.wikipedia.org/wiki/Ceva%27s_theorem

Unfortunately I failed to get that formula working last night (probably too much whiskey on my part).

It should return "1" if and only if the point is within the triangle, my attempt returned "1" regardless of the points location.
Think Slow......

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: Triangulation
« Reply #35 on: February 17, 2006, 11:34:20 AM »
With less Single Malt  :-):
Code: [Select]
;
; -- MeIsInTriangle
; Checks a point for inside a triangle.
; Arguments [Typ]:
;   Pnt = Point to test [LIST]
;   Pta = First triangle point [LIST]
;   Ptb = Second triangle point [LIST]
;   Ptc = Third triangle point [LIST]
; Return [Typ]:
;   > True if inside [BOOLEAN]
;   > False if outside [BOOLEAN]
; Notes:
;   - Triangle points must be ccw
;   - Points on edge are inside
;
(defun MeIsInTriangle (Pnt Pta Ptb Ptc / CroAbp CroBcp CroCap)
 (setq CroAbp (-
               (* (- (car Ptc) (car Ptb)) (- (cadr Pnt) (cadr Ptb)))
               (* (- (cadr Ptc) (cadr Ptb)) (- (car Pnt) (car Ptb)))
              )
       CroCap (-
               (* (- (car Ptb) (car Pta)) (- (cadr Pnt) (cadr Pta)))
               (* (- (cadr Ptb) (cadr Pta)) (- (car Pnt) (car Pta)))
              )
       CroBcp (-
               (* (- (car Pta) (car Ptc)) (- (cadr Pnt) (cadr Ptc)))
               (* (- (cadr Pta) (cadr Ptc)) (- (car Pnt) (car Ptc)))
              )
 )
 (and (>= CroAbp 0) (>= CroCap 0) (>= CroBcp 0))
)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Didge

  • Bull Frog
  • Posts: 211
Re: Triangulation
« Reply #36 on: February 20, 2006, 09:11:36 AM »
Well there we have it, conclusive proof that single malt is detrimental to lisp coding - that function works very well Jurg, thank-you.

I generally prefer using pure maths wherever possible as the coding usually runs cleaner and faster.
In this case however, I've tried running both of the "inside-checking" functions against a large data set and I can't find any measurable difference between them in terms of speed. They both work very well.

Thank-you both very much :-)
Think Slow......

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: Triangulation
« Reply #37 on: February 20, 2006, 11:33:04 AM »
Glad to help...
You're right, alcohol and programming are not compatible... :doa:
In my free time I prefer scotch single malt (my favorite: Talisker from Isle of Skye)... :-)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

Didge

  • Bull Frog
  • Posts: 211
Re: Triangulation
« Reply #38 on: February 21, 2006, 04:37:34 AM »
Talisker is indeed a mighty fine brew Jurg and one of my favourites too, in this case however the following was responsible. A nice peaty little number from Islay :-)

http://www.missionliquor.com/Store/Qstore/Qstore.cgi?CMD=011&PROD=1080182500&PNAME=Laphroaig+10+Years+Original+Cask+Strength+750ml
Think Slow......

bullah

  • Guest
Re: Triangulation
« Reply #39 on: January 29, 2014, 11:16:31 PM »
please share with me,  i use this

;*********************************************************************
; GET-Z  -  Lisp command to interpolate Z elevations from a 3D face                           *
; =====     using the plane equation.                                                                   *
;                                                                                                                       *
;*********************************************************************
(defun c:GET-Z ( / ENT P1 P1 P3 X Y X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 A B C D Z)

         (setq ENT (car (entsel "\nSelect 3DFace ")))
         (setq P (getpoint "\nSelect location > "))

         (setq P1 (cdr (assoc 10 (entget ENT)))
                 P2 (cdr (assoc 11 (entget ENT)))
                 P3 (cdr (assoc 12 (entget ENT)))
         )
         (setq  X (car P)
                  Y (cadr P)
                 X1 (car P1)
                 Y1 (cadr P1)
                 Z1 (caddr P1)
                 X2 (car P2)
                 Y2 (cadr P2)
                 Z2 (caddr P2)
                 X3 (car P3)
                 Y3 (cadr P3)
                 Z3 (caddr P3)
         )
 
; Add check here to determine if the point (P) is within the triangular
; 3dface, if so process the following code.
 
         (setq A (+ (* Y1 (- Z2 Z3)) (* Y2 (- Z3 Z1)) (* Y3 (- Z1 Z2)) ))
         (setq B (+ (* Z1 (- X2 X3)) (* Z2 (- X3 X1)) (* Z3 (- X1 X2)) ))
         (setq C (+ (* X1 (- Y2 Y3)) (* X2 (- Y3 Y1)) (* X3 (- Y1 Y2)) ))
         (setq D (-  (- (* A X1)) (* B Y1) (* C Z1) ))
         (setq Z (-  (- (* (/ A C) X))  (* (/ B C) Y)  (/ D C)  ))
         (prompt (strcat "\nElevation= " (rtos Z 2 3) "              "))

  (princ)
)

but some time ok, some time not ok.. sorry my english is bad. Im use autocad 2002
« Last Edit: January 29, 2014, 11:20:56 PM by bullah »

ymg

  • Guest
Re: Triangulation
« Reply #40 on: January 30, 2014, 08:31:38 AM »
Try this function:

Code - Auto/Visual Lisp: [Select]
  1. ;;****************************************************************************;
  2. ;; (getz p t1 t2 t3)                                                          ;
  3. ;; Given point p and triangle defined by points t1, t2, t3                    ;
  4. ;; Returns: (x y z) where z is on face of triangle.                           ;
  5. ;;                                                                            ;
  6. ;; By ymg  August 2013                                                        ;
  7. ;;****************************************************************************;
  8.  
  9. (defun getz (p t1 t2 t3 /  v1 v2)
  10.      
  11.    ; Calculating a normal vector with gile's functions in line.               ;
  12.    ; Note that I do not calculate the unit vector for the normal n.           ;
  13.    (setq v1 (mapcar '- t2 t1)
  14.          v2 (mapcar '- t3 t1)
  15.           n (list (- (* (cadr v1) (caddr v2)) (* (caddr v1) (cadr v2)))
  16.                   (- (* (caddr v1) (car v2)) (* (car v1) (caddr v2)))  
  17.                   (- (* (car v1) (cadr v2)) (* (cadr v1) (car v2)))    
  18.             )
  19.    )
  20.    (list (car p)(cadr p)(/ (apply '+ (mapcar '* n (mapcar '- t1 p)))(caddr n)))
  21.  )
  22.  

And if you need to check if your point is in a  given  triangle:

Code - Auto/Visual Lisp: [Select]
  1. (defun IsInTriangle_p (p p1 p2 p3 / x x1 x2 x3 y y1 y2 y3)
  2.    (setq x  (car p)  y  (cadr p)
  3.          x1 (car p1) y1 (cadr p1)
  4.          x2 (car p2) y2 (cadr p2)
  5.          x3 (car p3) y3 (cadr p3)
  6.    )
  7.    (=  (minusp (- (* (- x1 x) (- y2 y)) (* (- y1 y) (- x2 x))))
  8.        (minusp (- (* (- x2 x) (- y3 y)) (* (- y2 y) (- x3 x))))
  9.        (minusp (- (* (- x3 x) (- y1 y)) (* (- y3 y) (- x1 x))))
  10.    )  
  11. )
  12.  
« Last Edit: January 30, 2014, 08:40:08 AM by ymg »

bullah

  • Guest
Re: Triangulation
« Reply #41 on: January 31, 2014, 02:11:44 AM »
im use DTM.VLX to make 3D FACE the command is "DTM" and i use "DTMZ" command displays estimated elevations (Z-coordinates) of X-Y points (plan) picked in the area of the previously generated DTM model. but i want point xyz and text in plan. so im used

;*********************************************************************
; GET-Z  -  Lisp command to interpolate Z elevations from a 3D face                           *
; =====     using the plane equation.                                                                   *
;                                                                                                                       *
;*********************************************************************
(defun c:GETZ3 ( / ENT P1 P1 P3 X Y X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 A B C D Z)

         (setq ENT (car (entsel "\nSelect 3DFace ")))
         (setq P (getpoint "\nSelect location > "))

         (setq P1 (cdr (assoc 10 (entget ENT)))
                 P2 (cdr (assoc 11 (entget ENT)))
                 P3 (cdr (assoc 12 (entget ENT)))
         )
         (setq  X (car P)
                  Y (cadr P)
                 X1 (car P1)
                 Y1 (cadr P1)
                 Z1 (caddr P1)
                 X2 (car P2)
                 Y2 (cadr P2)
                 Z2 (caddr P2)
                 X3 (car P3)
                 Y3 (cadr P3)
                 Z3 (caddr P3)
         )
 
; Add check here to determine if the point (P) is within the triangular
; 3dface, if so process the following code.
 
         (setq A (+ (* Y1 (- Z2 Z3)) (* Y2 (- Z3 Z1)) (* Y3 (- Z1 Z2)) ))
         (setq B (+ (* Z1 (- X2 X3)) (* Z2 (- X3 X1)) (* Z3 (- X1 X2)) ))
         (setq C (+ (* X1 (- Y2 Y3)) (* X2 (- Y3 Y1)) (* X3 (- Y1 Y2)) ))
         (setq D (-  (- (* A X1)) (* B Y1) (* C Z1) ))
         (setq Z (-  (- (* (/ A C) X))  (* (/ B C) Y)  (/ D C)  ))
         (command "point" P)
         (command "change" "l" "" "p" "e" (rtos Z 2 3) "" )
         (command "text" "j" "bl" P "0.20" "90" (rtos z 2 3) )
         (command "change" "l" "" "p" "e" (rtos Z 2 3) "" )

  (princ)
)

;*********************************************************************

I have a problem to choose select 3dFace and point out 3dface can still have value. should have no value.  thanks  :-D
« Last Edit: January 31, 2014, 02:45:21 AM by bullah »

ymg

  • Guest
Re: Triangulation
« Reply #42 on: January 31, 2014, 04:26:20 AM »
Bullah,

You will always have problem trying to select a 3dFace in a mesh,
because every face is always double.

Ideally you would need to have a structure to keep all your points and 3dFaces and check
the location of the points within it.

Short of this, another technique is to select a point, with it create a fenced selection set in the +x direction,
do the same  in the -x direction.  Now the face that is common to both selection set is the face you are in.

Idea was given to me by robierzogg at Hispacad.

Following is an implementation:

Code - Auto/Visual Lisp: [Select]
  1. ;; Given the ename of a 3DFACE                                                ;
  2. ;; Returns List of 3 unique points forming that face                          ;
  3. (defun 3df->pl (en)
  4.   (defun distinct (l) (if l (cons (car l) (distinct (vl-remove (car l) l)))))
  5.   (setq ent (entget en)
  6.           l (distinct (mapcar '(lambda (a) (cdr (assoc a ent))) '(10 11 12 13)))
  7.   )
  8. )
  9.  
  10. ;; Given 2 List                                                               ;
  11. ;; Returns List of Elements Common to Both List.                              ;
  12. (defun common (l1 l2)
  13.   (if l1
  14.      (if (member (car l1) l2)
  15.         (cons (car l1) (common (cdr l1) l2))
  16.         (common (cdr l1) l2)
  17.      )
  18.   )
  19. )
  20.  
  21. ;; Given a Selection Set of Entities                                          ;
  22. ;; Returns List of ename                                                      ;
  23. (defun ss->enl ( ss / i l )
  24.     (if ss
  25.        (repeat (setq i (sslength ss))
  26.             (setq l (cons (ssname ss (setq i (1- i))) l))
  27.        )
  28.     )
  29. )
  30.  
  31.  
  32. (defun crossproduct (u v)
  33.   (list
  34.     (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
  35.     (- (* (car  v) (caddr u)) (* (car  u) (caddr v)))
  36.     (- (* (car  u) (cadr  v)) (* (car  v) (cadr  u)))
  37.   )
  38. )
  39.  
  40. (defun getz (p p1 p2 p3 / n)  
  41.    (setq p (list (car p) (cadr p) 0.)
  42.          n (crossproduct (mapcar '- p2 p1) (mapcar '- p3 p1))        
  43.    )
  44.    (list (car p)(cadr p)(/ (apply '+ (mapcar '* n (mapcar '- p1 p)))(caddr n)))
  45. )
  46.  
  47. ;; Return the maximum extent along the X of Selection Set of 3DFACE           ;
  48. (defun maxtr (ss /  i ent tmp bb rtn)
  49.   (setq  rtn 0)      
  50.   (repeat (setq i (sslength ss))
  51.      (setq ent (entget (ssname ss (setq i (1- i))))
  52.            tmp (mapcar '(lambda (a) (cdr (assoc a ent))) '(10 11 12 13))
  53.             bb (list (apply 'mapcar (cons 'min tmp)) (apply 'mapcar (cons 'max tmp)))
  54.            rtn (max rtn (- (caadr bb) (caar bb)))
  55.      )
  56.   )
  57. )    
  58.  
  59. ;|                                                          
  60.                   Función zpto                              
  61.                                                           |;
  62.  
  63. (defun c:zpto (/ p enl enl1 enl2 tr)
  64.   (setvar "osmode" 0)
  65.   (setq maxt (maxtr (ssget "_X"  '((0 . "3DFACE")))))  
  66.   (while (setq p (getpoint "\nPick a Point: "))
  67.    
  68.     ;buscamos la 3dface repetida
  69.     (setq enl1 (ss->enl (ssget "_F" (list p (list (+ (car p) maxt) (cadr p))) '((0 . "3DFACE"))))
  70.           enl2 (ss->enl (ssget "_F" (list p (list (- (car p) maxt) (cadr p))) '((0 . "3DFACE"))))
  71.     )
  72.     (cond
  73.        ((setq enl (common enl1 enl2)) (setq tr (3df->pl (car enl)))
  74.                                       (princ "\nPunto intersección: ")
  75.                                       (princ (getz p (car tr) (cadr tr) (caddr tr)))
  76.        )
  77.        (t (princ"\nPoint is Outside of  TIN"))
  78.     )
  79.   )
  80. )
  81.  

Note that in order to keep the Fenced Selection Set as small as possible,
we first scan all the faces and limit the search distance to the biggest
x distance of the faces.

To use issue command ZPTO, then simply pick points.  No need to select
the 3DFace.

ymg

ymg

  • Guest
Re: Triangulation
« Reply #43 on: February 01, 2014, 03:13:23 AM »
Bullah,

And here is a GETZ optimized for speed:

Code - Auto/Visual Lisp: [Select]
  1. (defun getz (p t1 t2 t3 / n1 n2 n3 x x1 x21 x31 y y1 y21 y31 z1 z21 z31)
  2.    (setq x  (car  p)  y  (cadr p)
  3.          x1 (car t1) y1 (cadr t1) z1 (caddr t1)        
  4.         x21 (- (car t2) x1)  y21 (- (cadr t2) y1) z21 (- (caddr t2) z1)
  5.         x31 (- (car t3) x1)  y31 (- (cadr t3) y1) z31 (- (caddr t3) z1)
  6.          n1 (- (* y21 z31) (* z21 y31))
  7.          n2 (- (* z21 x31) (* x21 z31))  
  8.          n3 (- (* x21 y31) (* y21 x31))                      
  9.    )  
  10.    (list x y (/ (+ (* (- x1 x) n1) (* (- y1 y) n2) (* z1 n3)) n3))
  11.  )
  12.  

This is around 3 times faster that the one with all the mapcar.

And similarly for IsInTriangle_p :

Code - Auto/Visual Lisp: [Select]
  1. (defun isintriangle_p (p p1 p2 p3 / x x1x x2x x3x y y1y y2y y3y)
  2.    (setq  x (car  p)          y (cadr  p)        
  3.         x1x (- (car p1) x)  y1y (- (cadr p1) y)
  4.         x2x (- (car p2) x)  y2y (- (cadr p2) y)
  5.         x3x (- (car p3) x)  y3y (- (cadr p3) y)  
  6.    )
  7.    (=  (minusp (- (* x1x y2y) (* y1y x2x)))
  8.         (minusp (- (* x2x y3y) (* y2y x3x)))
  9.         (minusp (- (* x3x y1y) (* y3y x1x)))
  10.    )  
  11. )
  12.  

Should give you approx. 15% speed improvement.

ymg
« Last Edit: February 01, 2014, 04:49:38 AM by ymg »

bullah

  • Guest
Re: Triangulation
« Reply #44 on: February 03, 2014, 12:17:31 AM »
Thank YMG.. i try put point its ok, when i try create text for the z value its not ok please help me.. Thank you very much

;; Given the ename of a 3DFACE                                                ;
;; Returns List of 3 unique points forming that face                          ;
(defun 3df->pl (en)
  (defun distinct (l) (if l (cons (car l) (distinct (vl-remove (car l) l)))))
  (setq ent (entget en)
          l (distinct (mapcar '(lambda (a) (cdr (assoc a ent))) '(10 11 12 13)))
  )
)
 
;; Given 2 List                                                               ;
;; Returns List of Elements Common to Both List.                              ;
(defun common (l1 l2)
  (if l1
     (if (member (car l1) l2)
        (cons (car l1) (common (cdr l1) l2))
        (common (cdr l1) l2)
     )
  )
)
 
;; Given a Selection Set of Entities                                          ;
;; Returns List of ename                                                      ;
(defun ss->enl ( ss / i l )
    (if ss
       (repeat (setq i (sslength ss))
            (setq l (cons (ssname ss (setq i (1- i))) l))
       )
    )
)
 
 
(defun crossproduct (u v)
  (list
    (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u)))
    (- (* (car  v) (caddr u)) (* (car  u) (caddr v)))
    (- (* (car  u) (cadr  v)) (* (car  v) (cadr  u)))
  )
)
 
(defun getz (p p1 p2 p3 / n)   
   (setq p (list (car p) (cadr p) 0.)
         n (crossproduct (mapcar '- p2 p1) (mapcar '- p3 p1))         
   )
   (list (car p)(cadr p)(/ (apply '+ (mapcar '* n (mapcar '- p1 p)))(caddr n)))
)
 
;; Return the maximum extent along the X of Selection Set of 3DFACE           ;
(defun maxtr (ss /  i ent tmp bb rtn)
  (setq  rtn 0)       
  (repeat (setq i (sslength ss))
     (setq ent (entget (ssname ss (setq i (1- i))))
           tmp (mapcar '(lambda (a) (cdr (assoc a ent))) '(10 11 12 13))
            bb (list (apply 'mapcar (cons 'min tmp)) (apply 'mapcar (cons 'max tmp)))
           rtn (max rtn (- (caadr bb) (caar bb)))
     )
  )
)   
 
;|                                                         
                  Función zpto                             
                                                          |;
 
(defun c:zpto1 (/ p enl enl1 enl2 tr bulah)
  (setvar "osmode" 0)
  (setq maxt (maxtr (ssget "_X"  '((0 . "3DFACE"))))) 
  (while (setq p (getpoint "\nPick a Point: "))
 
    ;buscamos la 3dface repetida
    (setq enl1 (ss->enl (ssget "_F" (list p (list (+ (car p) maxt) (cadr p))) '((0 . "3DFACE"))))
     enl2 (ss->enl (ssget "_F" (list p (list (- (car p) maxt) (cadr p))) '((0 . "3DFACE"))))
    )
    (cond
       ((setq enl (common enl1 enl2)) (setq tr (3df->pl (car enl)))                           
                                      (setq putpoint (getz p (car tr) (cadr tr) (caddr tr)))
                                      (command "point" putpoint )


       )

       (t (princ"\nPoint is Outside of  TIN"))
    )
  )
)