teykmcqh 发表于 2012-1-24 15:02:30

不错的帖子,正在学习这方面的资料,不过还得慢慢消化

T_T 发表于 2012-1-24 23:05:37

同上,很好的帖子

chlh_jd 发表于 2012-1-26 21:58:57

本帖最后由 chlh_jd 于 2012-1-26 21:59 编辑

集大成啊!
获取当前UCS矩阵参数我一直用楼主的版本简化版
(defun ss-getucsarg (/ f x y z o m)
(if (= (getvar "WORLDUCS") 0)
    (setq f T
    x (getvar "UCSXDIR")
    y (getvar "UCSYDIR")
    z (v^v x y)
    o (getvar "UCSORG")
    m (append
      (mapcar (function(lambda(x y)
          (append x (list y))
      )
          )
          (list x y z)
          o
      )
      (list (list 0. 0. 0. 1.))
      )
    )
    (setq f nil)
)
(list f m)
)获取变换矩阵,法国的gile是这样写的,大致和狂刀前辈的简化版相近

(defun gc:TMatrixFromTo(from to)
(append
    (mapcar
      (function
(lambda(v o)
    (append (trans v from to T) (list o))
)
      )
      (quote ((1. 0. 0.) (0. 1. 0.) (0. 0. 1.)))
      (trans (list 0. 0. 0.) to from)
    )
    (list (list 0. 0. 0. 1.))
)
)
;;(gc:TMatrixFromTo0 1)或(gc:TMatrixFromTo1 0)gile的旋转矩阵
;; gc:2dRotationMatrix
;; Returns the 4x4 transformation matrix for a rotation about the Z axis
;;
;; Arguments
;; base: the base point
;; ang: the angle in radians

(defun gc:2dRotationMatrix (base ang / mat)
(append
    (mapcar
      (function
   (lambda   (v1 v2)
   (append v1 (list v2))
   )
      )
      (setq mat   (list (list (cos ang) (- (sin ang)) 0)
         (list (sin ang) (cos ang) 0)
         (list 0. 0. 1.)
   )
      )
      (mapcar '- base (mxv mat base))
    )
    (list (list 0. 0. 0. 1.))
)
)


;; gc:3dRotationMatrix
;; Returns the 3d rotation matrix
;;
;; Arguments
;; org: the rotation base point
;; axis: the rotation axis vector
;; ang: the angle rotation (radians)

(defun gc:3dRotationMatrix (org axis ang)
(mxm
    (gc:TMatrixFromTo 0 axis)
    (mxm
      (gc:2dRotationMatrix (trans org 0 axis) ang)
      (gc:TMatrixFromTo axis 0)
    )
)
)配套函数

(defun mxv(m v)(mapcar(function(lambda (r)(vxv r v)))m))
;;
(defun vxv (v1 v2)
(apply (function +)(mapcar(function *) v1 v2)))
;;
(defun v^v (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)))
)
)

cheng5276 发表于 2012-4-20 12:08:12

都是高人,头晕了

smartstar 发表于 2012-9-5 16:39:31

脑袋大了!

ggdlove 发表于 2013-2-27 16:09:42

高飞鸟给出了基本的矩阵运算函数,值得学习。

yx5277 发表于 2013-4-2 11:00:47

请问如何判断究竟是在UCS下还是WCS下?

tm20038175 发表于 2013-4-3 21:05:02

这个能干什么?什么时候才用到矩阵转换。。。。

hnfsf 发表于 2014-9-2 23:52:21

做个记号,好好学习。

highflybir 发表于 2014-10-14 10:53:28

zhcsolution 发表于 2014-10-14 10:34 static/image/common/back.gif
这样做不是程序员的思路,应该用lisp+Arx 做。

不明白为何要动用到arx,本可以在LISP的范围内解决的,何必牵涉到另外一门语言?
页: 1 [2] 3
查看完整版本: 【飞鸟集】UCS的变换矩阵及其逆变换矩阵