Notifications
Clear all
[Closed] Compare two matrix
Aug 02, 2006 11:21 am
Why this won’t work?
m1 = (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])
m2 = (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])
if m1==m2 then
format "SAME!
"
else
format "NOT SAME!
"
Code returns “NOT SAME!”. What I do wrong?
3 Replies
Aug 02, 2006 11:21 am
I cannot explain why. I guess it something matrix specific.
You could do a per row comparison:
if m1[1] == m2[1] and m1[2] == m2[2] and m1[3] == m2[3] and m1[4] == m2[4] then
Georg
Aug 02, 2006 11:21 am
m1 = matrix3 [0,0,0] [0,0,0] [0,0,0] [0,0,0]
m2 = matrix3 [0,0,0] [0,0,0] [0,0,0] [0,0,0]
m2 = m1
if m1[1] == m2[1] then
format "Same
"
else
format "Not same
"
This one works. So seems like than max compare in this case memory pointer or something like that. Well I guess than this is good place for little compareMatrix function
Aug 02, 2006 11:21 am
And that little compareMatrix3 function
fn compareMatrix3 m1 m2 =
(
if (close_enough (m1[1].x) (m2[1].x) 10) and
(close_enough (m1[1].y) (m2[1].y) 10) and
(close_enough (m1[1].z) (m2[1].z) 10) and
(close_enough (m1[2].x) (m2[2].x) 10) and
(close_enough (m1[2].y) (m2[2].y) 10) and
(close_enough (m1[2].z) (m2[2].z) 10) and
(close_enough (m1[3].x) (m2[3].x) 10) and
(close_enough (m1[3].y) (m2[3].y) 10) and
(close_enough (m1[3].z) (m2[3].z) 10) and
(close_enough (m1[4].x) (m2[4].x) 10) and
(close_enough (m1[4].y) (m2[4].y) 10) and
(close_enough (m1[4].z) (m2[4].z) 10) then
return true
else
return false
)