Rotation matrix


Rotation matrix
#1
How do I calculate the cumulative sum or total of transformation matrices passed down from parent to child to grandchild, etc.?

The docs say:

Quote:Formally, the transformed point (u', v', w') can be calculated from point (u, v, w) as follows:
u' = a*u + b*v + c*w + x
v' = d*u + e*v + f*w + y
w' = g*u + h*v + i*w + z

but they do not say what a', b', c', d', etc. are. I am not very good with matrices, thanks!
Reply
RE: Rotation matrix
#2
(2020-02-23, 9:28)Michael Horvath Wrote: but they do not say what a', b', c', d', etc. are. I am not very good with matrices, thanks!
This is defined just above:
Code:
1 <colour> x y z a b c d e f g h i <file>
Reply
RE: Rotation matrix
#3
(2020-02-23, 10:36)Philippe Hurbain Wrote: This is defined just above:
Code:
1 <colour> x y z a b c d e f g h i <file>

I am trying to calculate what a', b', c', etc. (with apostrophe) of a MPD sub-model would be after processing the model. The values of a, b, c, etc. (without apostrophe) are obviously already known.
Reply
RE: Rotation matrix
#4
(2020-02-23, 11:22)Michael Horvath Wrote: I am trying to calculate what a', b', c', etc. (with apostrophe) of a MPD sub-model would be after processing the model. The values of a, b, c, etc. (without apostrophe) are obviously already known.
Sorry, misunderstood... You then need to perform a matrix multiplication.
if you have a submodel sm.dat containing reference to xxx.dat as
Code:
1 16 x y z a b c d e f g h i xxx.dat
and a model m.dat using transformed submodel sm:
Code:
1 16 x' y' z' a' b' c' d' e' f' g' h' i' sm.dat
then model m can be expressed as a transformed xxx.dat as
Code:
1 16 x" y" z" a" b" c" d" e" f" g" h" i" xxx.dat
with
Code:
x"=a'x+b'y+c'z+x'
y"=d'x+e'y+f'z+y'
z"=g'x+h'y+i'z+z'
and
Code:
a"=a'a+b'd+c'g
b"=a'b+b'e+c'h
c"=a'c+b'f+c'i
d"=d'a+e'd+f'g
e"=d'b+e'e+f'h
f"=d'c+e'f+f'i
h"=g'a+h'd+i'g
h"=g'b+h'e+i'h
i"=g'c+h'f+i'i
You can find gazillion of stuff on the web about matrix multiplication... hopefully you can wrap your head about it!
One big thing to remember, order of matrix IS significant. matrix A * matrix B is different from matrix B * matrix A!!!
Reply
RE: Rotation matrix
#5
Thank you! Hopefully that does the trick.

Question: After how many digits are people typically rounding values? There are (extremely) minor rounding errors in my calculations. Is this part of the specification too? MLCad seems to round after 6 digits.
Reply
RE: Rotation matrix
#6
(2020-02-23, 19:17)Michael Horvath Wrote: Thank you! Hopefully that does the trick.

Question: After how many digits are people typically rounding values? There are (extremely) minor rounding errors in my calculations. Is this part of the specification too? MLCad seems to round after 6 digits.

Not part of the spec but the standard is 4 decimal places for rotation matrices. To prevent rounding errors, in LDDP I use full floating point precision though all the math and then round as the final step before displaying the line.
Reply
RE: Rotation matrix
#7
(2020-02-23, 19:49)Orion Pobursky Wrote: Not part of the spec but the standard is 4 decimal places for rotation matrices. To prevent rounding errors, in LDDP I use full floating point precision though all the math and then round as the final step before displaying the line.

Thanks.

If anyone is interested, I created two new tools in this folder:

https://github.com/mjhorvath/Datsville/t...mpdcalcpos

### mpd2json

Tries to convert an MPD model file to JSON format. Caveat: ignores most meta commands, strips all comments.

### mpdcalcpos

Calculates the "final" or "flattened" coordinates and rotation matrices for sub-models and parts in an MPD file. The MPD file has to be converted to JSON first using mpd2json.

For the command line syntax, refer to the Windows batch files in the same folder. I should really rewrite these tools in Python when I get a chance.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 7 Guest(s)