・ (nentselp) が返す変換マトリックス (4x4)
から、変換尺度を得る
・ (nentsel) が返す変換マトリックス
(3x4) から、変換尺度を得る
(nentselp) が返す変換マトリックスは、次のように考えることができます
つまり、ベクトル Vx Vy Vz の長さを求めれば、尺度が分かります
;/////////////////////////////////////////////////////////////////////////////////////////////////; ;*** Jo_nobj_scal4.lsp ネストされたオブジェクトの尺度を取得 By Kamijo 2003/10/01***; ; (nentselp が返す4X4のマトリックスから求める) ; ;/////////////////////////////////////////////////////////////////////////////////////////////////; (defun Jo_nobj_scal4 ( / mat ent n s_e scal) (while (not mat) (while (not ent) (initget " ") (setq ent (nentselp "\nINSERT図形上の点を指示 または <終了>:")) (if (= ent "") (exit) ) ) (if (= 4 (length ent)) (setq mat (caddr ent)) (setq ent nil) ) ) (setq mat (reverse (cdr (reverse mat))));4x4の行列の最後の行を削除; (setq n 0) (repeat 3 (setq s_e (sqrt (apply '+ (mapcar '(lambda (x) (expt (nth n x) 2)) mat)))) (setq n (1+ n)) (setq scal (append scal (list s_e))) ) (mapcar '(lambda (a b) (print (strcat a ":" (rtos b) "x"))) '("X" "Y" "Z") scal) (princ) )
(nentsel)が返す変換マトリックスは、行と列が入れ替わるので、次のようになります
;/////////////////////////////////////////////////////////////////////////////////////////////////; ;*** Jo_nobj_scal3.lsp ネストされたオブジェクトの尺度を取得 By Kamijo 2003/10/01***; ; (nentsel が返す3X4のマトリックスから求める) ; ;/////////////////////////////////////////////////////////////////////////////////////////////////; (defun Jo_nobj_scal3 ( / ent mat n s_e scal) (while (not mat) (while (not ent) (initget " ") (setq ent (nentsel "\nINSERT図形を選択 または <終了>:")) (if (= ent "") (exit) ) ) (if (= 4 (length ent)) (setq mat (caddr ent)) (setq ent nil) ) ) (setq mat (reverse (cdr (reverse (caddr ent))))) (setq n 0) (repeat 3 (setq s_e (sqrt (apply '+ (mapcar '(lambda (x) (expt x 2)) (nth n mat))))) (setq n (1+ n)) (setq scal (append scal (list s_e))) ) (mapcar '(lambda (a b) (print (strcat a ":" (rtos b) "x"))) '("X" "Y" "Z") scal) (princ) )