Summing matrices


Re: Summing matrices
#4
Hi Michael,

Here's some pseudo-code. I don't think an excel spreadsheet would tell you anything much.

Michael Horvath Wrote:I know that the XYZ coordinates can simply be added.

Actually no they cannot. You must rotate the displacement of C relative to B.

Tim


Code:
# Multiply a vector by a matrix
function Xn=MatVec(R,X)
   for i from 1 to 3
      Xn(i)=0
      for j from 1 to 3
         Xn(i)=Xn(i)+R(i,j)*X(j)
      end
   end
endfunction

# Multiply two matrices
function Rn=MatMat(R1,R2)
   for i from 1 to 3
      for j from 1 to 3
         Rn(i,j)=0
         for k from 1 to 3
            Rn(i,j)=Rn(i,j)+R1(i,k)*R2(k,j)
         end
      end
   end
endfunction

# Find the rotation and displacement of A relative to C [XCA and RCA]
# using # the rotation and displacement of A relative to B [XBA and RBA]
# and B relative to C [XCB and RCB]
function [XCA,RCA]=Compound(XBA,RBA,XCB,RCB)
   RCA=MatMat(RCB,RBA)
   XCBp=MatVec(RBA,XCB)

   for i from 1 to 3
      XCA(i)=XBA(i) + XCBp(i)
   end
endfunction
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Summing matrices - by Michael Horvath - 2014-07-04, 1:16
Re: Summing matrices - by Tim Gould - 2014-07-04, 9:18
Re: Summing matrices - by Michael Horvath - 2014-07-04, 20:46
Re: Summing matrices - by Tim Gould - 2014-07-06, 0:36
Re: Summing matrices - by Travis Cobbs - 2014-07-06, 6:21
Re: Summing matrices - by Philippe Hurbain - 2014-07-06, 14:39
Re: Summing matrices - by Tim Gould - 2014-07-07, 0:38
Re: Summing matrices - by Michael Horvath - 2014-07-08, 15:24
Re: Summing matrices - by Travis Cobbs - 2014-07-08, 17:04

Forum Jump:


Users browsing this thread: 2 Guest(s)