Rotation matrix - Printable Version +- LDraw.org Discussion Forums (https://forums.ldraw.org) +-- Forum: LDraw Programs (https://forums.ldraw.org/forum-7.html) +--- Forum: LDraw File Processing and Conversion (https://forums.ldraw.org/forum-22.html) +--- Thread: Rotation matrix (/thread-23911.html) |
Rotation matrix - Michael Horvath - 2020-02-23 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: but they do not say what a', b', c', d', etc. are. I am not very good with matrices, thanks! RE: Rotation matrix - Philippe Hurbain - 2020-02-23 (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> RE: Rotation matrix - Michael Horvath - 2020-02-23 (2020-02-23, 10:36)Philippe Hurbain Wrote: This is defined just above: 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. RE: Rotation matrix - Philippe Hurbain - 2020-02-23 (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 Code: 1 16 x' y' z' a' b' c' d' e' f' g' h' i' sm.dat Code: 1 16 x" y" z" a" b" c" d" e" f" g" h" i" xxx.dat Code: x"=a'x+b'y+c'z+x' Code: a"=a'a+b'd+c'g One big thing to remember, order of matrix IS significant. matrix A * matrix B is different from matrix B * matrix A!!! RE: Rotation matrix - Michael Horvath - 2020-02-23 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. RE: Rotation matrix - Orion Pobursky - 2020-02-23 (2020-02-23, 19:17)Michael Horvath Wrote: Thank you! Hopefully that does the trick. 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. RE: Rotation matrix - Michael Horvath - 2020-02-23 (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/tree/master/helper_scripts/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. |