Hi,
Thanks CAB, even I think this post is quite confuse due to my poor English...
How can I get the Matrix from the UCS-Origin & angle of UCS X-Axis or a point of UCS X-Axis ?
If can get the Matrix , I can use the gile's function or others function to trans pt by matrix .
I am not sure to understand what you're asking for, but using Vladimir Nesterovsky's mxv routine and gc:CrossProduct (previously named: v^v) you can build the 3X3 transformation matrix form WCS to the current UCS.
;; MXV
;; Apply a transformation matrix to a vector -Vladimir Nesterovsky-
(defun mxv (m v)
(mapcar (function (lambda (r) (apply '+ (mapcar '* r v)))) m)
)
;; gc:CrossProduct
;; Returns the cross product of 2 vectors
(defun gc:CrossProduct (v1 v2)
(list (- (* (cadr v1) (caddr v2)) (* (caddr v1) (cadr v2)))
(- (* (caddr v1) (car v2)) (* (car v1) (caddr v2)))
(- (* (car v1) (cadr v2)) (* (cadr v1) (car v2)))
)
)
Here're 3 different ways to get this 3X3 matrix, they return the same result:
(setq mat (list (getvar 'ucsxdir) (getvar 'ucsydir) (gc:CrossProduct (getvar 'ucsxdir) (getvar 'ucsydir))))
(setq mat (list (getvar 'ucsxdir) (getvar 'ucsydir) (trans '(0. 0. 1.) 1 0 T)))
(setq mat (mapcar '(lambda (x) (trans x 1 0 T)) '((1. 0. 0.) (0. 1. 0.) (0. 0. 1.))))
A 3X3 transformation matrix doesn't care about displacement (UCS origin), but this matrix is enough to transform vectors with Vladimir Nesterovsky's mxv:
(mxv mat '(10. 20. 30.))
returns the same result as:
(trans '(10. 20. 30.) 0 1 T)
If you have to transform points, you must take care of the UCS origin and displace the the vector.
These 3 expressions return the same result:
(mapcar '- (mxv mat '(10. 20. 30.)) (mxv mat (getvar 'ucsorg)))
(mapcar '+ (mxv mat '(10. 20. 30.)) (trans '(0. 0. 0.) 0 1))
(trans '(10. 20. 30.) 0 1)