Re: Summing matrices
 July 05, 2014 05:36PM Website Administrator Steering Committee Member LDraw Part Author/Reviewer Registered: 4 years agoPosts: 1,112
Hi Michael,

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

Quote
Michael Horvath
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

```# 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
```

Edited 2 time(s). Last edit at 2014-07-05 05:38PM by Tim Gould.
SubjectAuthorViewsPosted
Michael Horvath444July 03, 2014 06:16PM
Tim Gould216July 04, 2014 02:18AM
Michael Horvath212July 04, 2014 01:46PM
Tim Gould269July 05, 2014 05:36PM
Travis Cobbs248July 05, 2014 11:21PM
Philippe Hurbain228July 06, 2014 07:39AM
Tim Gould236July 06, 2014 05:38PM
Michael Horvath198July 08, 2014 08:24AM
Travis Cobbs251July 08, 2014 10:04AM

Sorry, only registered users may post in this forum.