;;; analyze of irregular polygon - problem of finding shape of irregular polygon based on input data refering all measured distances between all point pairs ;;;
;;; dedicated topic : http://www.theswamp.org/index.php?topic=57402.0 ;;;
(defun c:decomposition
+composition
( / *error* uniquetrl comb trianglst LM:popup processtr makelwtr ci1xci2
cmd pea lw lwx pl plcomb trl edgesl p chk lws tr el regs ss reg enx
)
(vl-load-com) ;;; load ActiveX extensions (VLA functions) ;;;
(command-s "_.undo" "_e")
)
)
)
)
)
)
(uniquetrl
)
))
x
)
))
)
)
)
)
)
(defun comb
( lst
/ ll r
) )
r
)
)
)
)
r
)
(defun trianglst
( plcomb
/ ll trl r
) )
)
)
)
)
)
)
)
)
r
)
)
)
)
)
r
)
;; Popup - Lee Mac
;; A wrapper for the WSH popup method to display a message box prompting the user.
;; ttl - [str] Text to be displayed in the pop-up title bar
;; msg - [str] Text content of the message box
;; bit - [int] Bit-coded integer indicating icon & button appearance
;; Returns: [int] Integer indicating the button pressed to exit
(defun LM:popup
( ttl msg bit
/ wsh rtn
) )
)
)
)
)
(defun processtr
( tr p ang
/ p1 p2 p3 q edl tre ll
) (makelwtr p1 p2 p3)
lws
)
)
)
)
)
))
x
)
))
trl
)
)
)
)
)
)
)
)
)
))
)
))
x
)
))
trl
)
)
)
)
(defun makelwtr
( p1 p2 p3
) (cons 100 "AcDbPolyline") )
)
)
;; 2-Circle Intersection (trans version) - Lee Mac
;; Returns the point(s) of intersection between two circles
;; with centres c1,c2 and radii r1,r2
(defun ci1xci2
( c1 r1 c2 r2
/ n d1 x z
) (equal d1
(+ r1 r2
) 1e
-6
) )
)
)
(setq z
(abs (/ (- (+ (* r1 r1
) (* d1 d1
)) (* r2 r2
)) (+ d1 d1
)))) )
)
)
)
)
)
(command-s "_.undo" "_e")
)
)
(command-s "_.undo" "_m")
)
lw
))
lwx
)
)
)
)
)
))
lwx
)
)
)
(setq trl
(uniquetrl
(trianglst plcomb
))) ;;; trl=(((n11 n12 d11) (n12 n13 d12) (n13 n11 d13)) ((n21 n22 d21) (n22 n23 d22) (n23 n21 d23)) ((n31 n32 d31) (n32 n33 d32) (n33 n31 d33)) ... ) ;;; (princ trl) ;;;
;;; ... we are here with triangles ... ;;;
;;; To tackle the problem, we should think of 3D/2D (spacial) triangular dimensional determination in some kind of point additional order : 3 points - triangle = 3; 4 pts = 3 points - triangle + 3 additional edges from each point of triangle to 4th point = 6 ::: formulation : n*(n-1)/2 ::: 4*(4-1)/2=6 ; 5 pts ::: 5*(5-1)/2=10 ; ...
;;; Order goes like this : 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
trl
)
(prompt "\nLooping haven't passed correctly - some triangles from list trl haven't been processed...") (if (/= 6 (LM:popup
"CONTINUE WITH PROCESSING - YES / QUIT - NO" "Choose option : " 36)) )
)
)
)
)
)
(processtr tr p 0.0)
)
(if (= 6 (LM:popup
"RESULTING TRIANGLES COMPOSED - PROCEED TO UNION TO FINAL OUTLINE LWPOLY" "Choose option : " 36)) el
)
) regs
)
)
)
)
)
)
)
)
(vl-cmdf "_.pedit" "_m" ss
"" "_j") )
)
)
)
)
)
)
)
)
)
)
)
(prompt "\nSome triangles haven't been processed...") (if (= 6 (LM:popup
"SHOW UNPROCESSED TRIANGLES" "Choose option : " 36)) )
)
)
(prompt "\nFor UNDO - type \"UNDO\" - \"Back\" option...") )
(prompt "\nMissed..., or picked wrong entity type, or picked LWPOLYLINE not closed, or picked LWPOLYLINE not polygonal - has arced segments...") (if (= 4 (LM:popup
"DECOMPOSITION+COMPOSITION - IRREGULAR POLYGON" "Choose option : " 53)) (c:decomposition+composition)
)
)
)
(*error* nil)
)