Even-length sided rotation transforms in templates (re: 29-Jul stream)

Just posting this here for @Ponder as requested at the end of the livestream.

The x/z to the right each grid are the absolute transform offsets required to move the new, rotated origin (*) to the proper position (@), followed - if non-zero - by the appropriate axis equation (based on Tony’s lua code written during the stream). I figured they’d be useful as the wx/hz value used actually flips based on the rotation (which wasn’t immediately evident when working with same-length even-sided objects like the 2x2 crate).

I used a smaller 4x3 and a larger 6x3 to show the equations work across differing sized objects (with mixed odd/even sides!) as my initial assumption that ceiling(length/2) was required was wrong and only works when the origin is centred (a centred-origin object not having any of the problems associated with this template bug). This works just as effectively if both sides are of an even-value size (though those sizes don’t have to match).

This all assumes that the origin point of objects with at least one even side length is in the lower-left [0,0] coordinate (as was the case for the 2x2 crate and, I believe, the 1x2 window, as well). This does work for the 1x2 window object but I left that out for brevity. (:

wx = Object's X width      / hz = Object's Z height
@  = Object's origin point /  * = Object's origin after rotation

wx = 4 / hz = 3

oooo..                         ...*oo
oooo..  x =  0                 ...ooo  x =  0  / 
@ooo..  z =  0                 ...ooo  z = -3  / z -= wx-1
......                         ...@oo
......                         ......
......                         ......

......                         ......
......  x = -3  / x -= wx-1    ......  x = -2  / x -= hz-1
......  z = -2  / z -= hz-1    ooo...  z =  0  / 
..ooo*                         ooo...
..oooo                         ooo...
..@ooo                         @o*...


wx = 6 / hz = 3

oooooo..                            .....*oo
oooooo..  x =  0                    .....ooo  x =  0  / 
@ooooo..  z =  0                    .....ooo  z = -5  / z -= wx-1
........                            .....ooo
........                            .....ooo
........                            .....@oo
........                            ........
........                            ........

........                            .........
........  x = -5  / x -= wx-1       .........  x = -2  / x -= hz-1
........  z = -2  / z -= hz-1       ooo......  z =  0  / 
........                            ooo......
........                            ooo......
..ooooo*                            ooo......
..oooooo                            ooo......
..@ooooo                            @o*......

Hope this helps!
-TJ

4 Likes