(defun c:findclosestpointtonestedinblkref
( / findclosestpointtonestedinblkref refgeom trp mxm mxv LM:InverseMatrix processclosestpointto processclosestpointtoinv collectblkrefs collectallentsfromref collectallcurvesnestedinblkrefwithparentrefassociations stblkref blkref wcspt p
)
(defun findclosestpointtonestedinblkref
( blkref wcspt
/ pl curreflst rg
)
(foreach curref
(setq curreflst
(collectallcurvesnestedinblkrefwithparentrefassociations blkref
)) )
)
;; RefGeom (gile)
;; Returns a list whose first item is a 3x3 transformation matrix and
;; second item the object insertion point in its parent (xref, block or space)
(defun refgeom
( ent
/ ang enx mat ocs
) )
(mxm
'(
(1.0 0.0 0.0)
(0.0 1.0 0.0)
(0.0 0.0 1.0)
)
)
(mxm
'(0.0 0.0 1.0)
)
)
)
)
)
)
)
)
;; Matrix Transpose - Doug Wilson
;; Args: m - nxn matrix
)
;; Matrix x Matrix - Vladimir Nesterovsky
;; Args: m,n - nxn matrices
)
;; Matrix x Vector - Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
)
;;--------------------=={ Inverse Matrix }==------------------;;
;; ;;
;; Implements the Gauss-Jordan Elimination algorithm to ;;
;; inverse a non-singular nxn matrix. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: m - nxn Matrix ;;
;;------------------------------------------------------------;;
;; Returns: Matrix inverse, or nil if matrix is singular ;;
;;------------------------------------------------------------;;
(defun LM:InverseMatrix
( m
/ _identity _eliminate p r x
)
)
)
(defun _eliminate
( m p
) )
)
m
)
)
)
r
(cons p
(_eliminate r p
)) )
)
)
)
(defun processclosestpointto
( parentlst pt
/ parent
) )
)
pt
)
(defun processclosestpointtoinv
( parentlst pt
/ child
) (setq pt
((lambda ( matveclst
) (mxv
(LM:InverseMatrix
(car matveclst
)) (mapcar '
- pt
(cadr matveclst
)))) (refgeom child
))) )
)
pt
)
(defun collectblkrefs
( blkref curve
/ el ee
) (setq el
(collectallentsfromref blkref
)) )
)
(setq blkrefinl blkrefin
) )
)
)
(collectblkrefs ee curve)
nil
)
)) el
)
blkrefinl
)
(defun collectallentsfromref
( blkref
/ e el
)
)
el
)
(defun collectallcurvesnestedinblkrefwithparentrefassociations
( blkref
/ blkrefinl e el ex gg g q f
)
)
(setq el
(collectallentsfromref blkref
)) ( (wcmatch (cdr (assoc 0 ex
)) "*POLYLINE,SPLINE,XLINE,LINE,RAY,ARC,CIRCLE,ELLIPSE,HELIX") (setq blkrefinl
(collectblkrefs stblkref e
)) (setq blkrefinl
(cons blkref blkrefinl
)) )
)
)
)
)
)
(setq blkrefinl
nil gg
nil g
nil q
nil f
nil) )
(collectallcurvesnestedinblkrefwithparentrefassociations e)
)
)
)
curreflst
)
)
)
(prompt "\nMissed or picked wrong entity type...") )
(princ (setq p
(findclosestpointtonestedinblkref blkref wcspt
))) )