Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[irtgeo.l] enable :rotation-axis :xy :yz :zx :yx :zy :xz #568

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions irteus/irtgeo.l
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
)
(:difference-position
(coords &key (translation-axis t))
"return difference in position of given coords, translation-axis can take (:x, :y, :z, :xy, :yz, :zx)."
"return difference in position of given coords, translation-axis can take (:x, :y, :z, :xy, :yz, :zx, :yx, :zy, :xz)."
(let ((dif-pos
(send self :inverse-transform-vector (send coords :worldpos))))
(case
Expand All @@ -69,7 +69,7 @@
dif-pos))
(:difference-rotation
(coords &key (rotation-axis t))
"return difference in rotation of given coords, rotation-axis can take (:x, :y, :z, :xx, :yy, :zz, :xm, :ym, :zm)"
"return difference in rotation of given coords, rotation-axis can take (:x, :y, :z, :xy, :yz, :zx, :yx, :zy, :xz, :xx, :yy, :zz, :xm, :ym, :zm)"
(labels
((need-mirror-for-nearest-axis
(coords0 coords1 axis)
Expand All @@ -88,6 +88,19 @@
(setq dif-rot
(transform (transpose (send self :worldrot))
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))
((:xy :yx :yz :zy :zx :xz)
(setq a0 (send self :axis (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about use 'let'. The following code is my suggestion.

((:xy :yx :yz :zy :zx :xz)
        (let ((ax1 (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y)))
              (ax2 (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z))))
          (setq a0 (send self :axis ax1)
                a1 (send coords :axis ax1))
          (setq dif-rot
                (transform (transpose (send self :worldrot))
                           (scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1)))))
          (let ((self-coords (send (send self :copy-worldcoords) :rotate (norm dif-rot) dif-rot)))
            (setq a0 (send self-coords :axis ax2)
                  a1 (send coords :axis ax2))
            (setq dif-rot
                  (transform (transpose (send self-coords :worldrot))
                             (scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I fixed. 815f8b4

a1 (send coords :axis (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y))))
(setq dif-rot
(transform (transpose (send self :worldrot))
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1)))))
(let ((self-coords (send (send self :copy-worldcoords) :rotate (norm dif-rot) dif-rot)))
(setq a0 (send self-coords :axis (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z)))
a1 (send coords :axis (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z))))
(setq dif-rot
(transform (transpose (send self-coords :worldrot))
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))
)
((:xx :yy :zz)
(let ((axis (case rotation-axis (:xx :x) (:yy :y) (:zz :z))) a0 a2)
(setq a0 (send self :axis axis))
Expand Down