Skip to content

Commit 815f8b4

Browse files
committed
[iregeo.l :difference-rotation] use let, and fix 0 norm condition
1 parent 85c060d commit 815f8b4

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

irteus/irtgeo.l

+14-11
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,21 @@
8989
(transform (transpose (send self :worldrot))
9090
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))
9191
((:xy :yx :yz :zy :zx :xz)
92-
(setq a0 (send self :axis (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y)))
93-
a1 (send coords :axis (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y))))
94-
(setq dif-rot
95-
(transform (transpose (send self :worldrot))
96-
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1)))))
97-
(let ((self-coords (send (send self :copy-worldcoords) :rotate (norm dif-rot) dif-rot)))
98-
(setq a0 (send self-coords :axis (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z)))
99-
a1 (send coords :axis (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z))))
92+
(let ((ax1 (case rotation-axis ((:xy :yx) :z) ((:yz :zy) :x) ((:zx :xz) :y)))
93+
(ax2 (case rotation-axis ((:xy :yx) :x) ((:yz :zy) :y) ((:zx :xz) :z))))
94+
(setq a0 (send self :axis ax1)
95+
a1 (send coords :axis ax1))
10096
(setq dif-rot
101-
(transform (transpose (send self-coords :worldrot))
102-
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))
103-
)
97+
(transform (transpose (send self :worldrot))
98+
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1)))))
99+
(let ((self-coords (if (= 0.0 (norm dif-rot))
100+
self
101+
(send (send self :copy-worldcoords) :rotate (norm dif-rot) (normalize-vector dif-rot)))))
102+
(setq a0 (send self-coords :axis ax2)
103+
a1 (send coords :axis ax2))
104+
(setq dif-rot
105+
(transform (transpose (send self-coords :worldrot))
106+
(scale (acos (v. a0 a1)) (normalize-vector (v* a0 a1))))))))
104107
((:xx :yy :zz)
105108
(let ((axis (case rotation-axis (:xx :x) (:yy :y) (:zz :z))) a0 a2)
106109
(setq a0 (send self :axis axis))

0 commit comments

Comments
 (0)