Rotating objects does not align?
Moderators: dorpond, trevor, Azhrei
Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
Rotating objects does not align?
I have been trying to get double doors to align properly with a rotation rather than with a flip. I can of course flip an object and it will stay aligned with a duplicate of the non flipped object. But why does rotating an object cause it to be a fraction of a pixel misaligned with the other non flipped object?
I've verified this by editing the graphic in Photoshop, making sure that the top half is exactly the same as the bottom half and each half is centered correctly.
Here is a screenshot where the top doors are not aligned because one was rotated. The bottom doors were flipped rather than rotated and are aligned properly. If you were to zoom in on the MT map, the top doors are less than a pixel off. The further out you zoom, the more they look misaligned.
I've verified this by editing the graphic in Photoshop, making sure that the top half is exactly the same as the bottom half and each half is centered correctly.
Here is a screenshot where the top doors are not aligned because one was rotated. The bottom doors were flipped rather than rotated and are aligned properly. If you were to zoom in on the MT map, the top doors are less than a pixel off. The further out you zoom, the more they look misaligned.
- JamzTheMan
- Great Wyrm
- Posts: 1872
- Joined: Mon May 10, 2010 12:59 pm
- Location: Chicagoland
- Contact:
Re: Rotating objects does not align?
Is the graphic an odd or even number of pixels high? I would imagine the door should be an odd number of pixels to have an exact middle to rotate on otherwise that may be the source of the issue?
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork
Re: Rotating objects does not align?
The pixels being even or odd shouldn't matter since flipping after the rotation should put the image in the exact same position (only because the top and bottom halves of the image are exact duplicates).
Basically, the point between the 2 middle horizontal pixels is your center point. Which is where MT should be rotating. But even rotating from a "center" point one pixel higher or lower should still give proper results if you then flip the image after rotating it.
I made a new door with a black line to make an odd pixel count like you suggested (not that it will have any effect in this instance). The result is still the same as expected. But here are 3 screenshots zoomed at different distances.
Up close, you can see the pixels and see that the doors are misaligned a fraction of a pixel. There is no way to nudge them up or down to align correctly because the rotation does not seem to rotate around a pixel count.
The farther you zoom out, the more they look misaligned.
BTW, the only reason I'm bringing this up rather than flipping them instead of rotating then flipping them is because I'm using them with Wolph42's BoT double animated doors macro with attached VBL. It requires the 2nd door to rotate for the VBL to be placed correctly. But now it looks like my MT doors are glitched. :p
Basically, the point between the 2 middle horizontal pixels is your center point. Which is where MT should be rotating. But even rotating from a "center" point one pixel higher or lower should still give proper results if you then flip the image after rotating it.
I made a new door with a black line to make an odd pixel count like you suggested (not that it will have any effect in this instance). The result is still the same as expected. But here are 3 screenshots zoomed at different distances.
Up close, you can see the pixels and see that the doors are misaligned a fraction of a pixel. There is no way to nudge them up or down to align correctly because the rotation does not seem to rotate around a pixel count.
The farther you zoom out, the more they look misaligned.
BTW, the only reason I'm bringing this up rather than flipping them instead of rotating then flipping them is because I'm using them with Wolph42's BoT double animated doors macro with attached VBL. It requires the 2nd door to rotate for the VBL to be placed correctly. But now it looks like my MT doors are glitched. :p
Re: Rotating objects does not align?
I guessed this had to do with the bot. And I can confirm this issue (pixels not aligning).
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rotating objects does not align?
Is this a problem in b89, or the custom build? I recall a very strange error (totally unrelated) where a person could move his token in to certain squares with snap to grid. I loaded his campaign and sure enough, it would just skip right over certain squares. Then I looked at the x,y coords.. about 1mill+ I figured the math was breaking down when at extreme x,y coordinates.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Rotating objects does not align?
I know that the math breaks for getTokenX/Y for extreme (e.g. 650) coordinates as in that case it returns a higher (651) value. But i don't know if thats related to this issue.aliasmask wrote:Is this a problem in b89, or the custom build? I recall a very strange error (totally unrelated) where a person could move his token in to certain squares with snap to grid. I loaded his campaign and sure enough, it would just skip right over certain squares. Then I looked at the x,y coords.. about 1mill+ I figured the math was breaking down when at extreme x,y coordinates.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rotating objects does not align?
I take my earlier confirmation back. I did a more thorough test this time and create one token of 50x50 px with alternating red and white. Then I placed it in a 50px grid maptool map and copied a 180 rotated token next to it:
as you can see, they align perfectly.
and just to be thorough, here a 'door' of 2 px thck in a 50px token. (I tested this on size medium and size large, but that result in the same picture.)
zoomed out:
I also checked these at extreme coords (20,000+ RMC+) but no difference.
and finally I flipped them both horizontally, but again: same picture. So the only conclusion that can be derived from this is that the 'door' or Oryan is not in dead centre.
I think (but not tested) that the issue lies with e.g. a door image of 101x101 px which is then forced on a 50px grid. I can imagine that some pixel shift will take place and since its a half px its impossible to align on a 50px grid. edit: tested and nope, then too the line aligns perfectly.
result
and just to be thorough, here a 'door' of 2 px thck in a 50px token. (I tested this on size medium and size large, but that result in the same picture.)
Spoiler
Spoiler
and finally I flipped them both horizontally, but again: same picture. So the only conclusion that can be derived from this is that the 'door' or Oryan is not in dead centre.
I think (but not tested) that the issue lies with e.g. a door image of 101x101 px which is then forced on a 50px grid. I can imagine that some pixel shift will take place and since its a half px its impossible to align on a 50px grid. edit: tested and nope, then too the line aligns perfectly.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rotating objects does not align?
My maps and doors are set at 100px grid size. Would that make a difference? Also, as I said, the closer you zoom in, the better aligned it looks. So you can zoom in close enough where it looks correct. The farther you zoom out, the worse it looks.
The left doors in your last example still look misaligned. The bounding boxes do not look lined up, which is the same effect I get when rotating objects (can't align a rotated bounding box by nudging because it is always off by less than a pixel).
My door graphics are 400x100. As I said earlier, for testing, I used Photoshop to copy the bottom half of the door, delete the top half, pasted and flipped the other half and positioned it so that both sides are exactly the same. It is centered along the horizontal middle. When I place it in MT, I set the size to gargantuan (100px grid map) so that the door appears to be large (fits in 2 squares).
Could it be a graphics card issue where it just appears to be misaligned in MT?
Here is a door if anyone wants to test it:
The left doors in your last example still look misaligned. The bounding boxes do not look lined up, which is the same effect I get when rotating objects (can't align a rotated bounding box by nudging because it is always off by less than a pixel).
My door graphics are 400x100. As I said earlier, for testing, I used Photoshop to copy the bottom half of the door, delete the top half, pasted and flipped the other half and positioned it so that both sides are exactly the same. It is centered along the horizontal middle. When I place it in MT, I set the size to gargantuan (100px grid map) so that the door appears to be large (fits in 2 squares).
Could it be a graphics card issue where it just appears to be misaligned in MT?
Here is a door if anyone wants to test it:
Re: Rotating objects does not align?
I'll check out your door later.the bounding box looks disaligned because of the red colors I used. But believe me I checked all kinds of zoom levels.
edit: AH Now I get it. I can confirm your issue. This issue happens when you 'unsnap' the tokens and then move them. In that case its impossible to align them. This is also the case for the tests I did earlier.
The workaround is to snap them, set them up and unsnap them. That way they stay aligned correctly.
I don't know if the devs can fix this issue as the disalignment is very tiny: her you can see the effect:. As you can see the token on the right is rotated 180 degrees and is a tiny bit disaligned to the grid. The effect switches with each zoom level.
and if anyone else wishes to test, here's the token:
edit: AH Now I get it. I can confirm your issue. This issue happens when you 'unsnap' the tokens and then move them. In that case its impossible to align them. This is also the case for the tests I did earlier.
The workaround is to snap them, set them up and unsnap them. That way they stay aligned correctly.
I don't know if the devs can fix this issue as the disalignment is very tiny: her you can see the effect:
Spoiler
and if anyone else wishes to test, here's the token:
Spoiler
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rotating objects does not align?
I'm trying that trick but the door still ends up misaligned.wolph42 wrote:I can confirm your issue. This issue happens when you 'unsnap' the tokens and then move them. In that case its impossible to align them. This is also the case for the tests I did earlier.
The workaround is to snap them, set them up and unsnap them. That way they stay aligned correctly.
I turn snapping on, drop a door from my library, copy/paste a 2nd door, rotate it, flip it vertical, and it is misaligned.
Anyway, it doesn't seem like we are getting much feedback about this issue. :p
As a graphics guy, this is a very irritating visual to see on a map.
Re: Rotating objects does not align?
indeed ! which is funny, cause try my trick with this door:
edit: i compared your door and this one on the same map next to eachother and noticed that the black line you drew was 1pixel ABOVE the grid, so obviously it disaligns!! Try this on a 50px grid, its also noticeable on a 100px grid but barely. Anyway its more then one issue. There's an issue with unsnapped tokens that cannot be aligned properly to the grid when rotated and apparently there is an issue with your door, cause with my door attached here I can only replicate your issue unsnapped.GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rotating objects does not align?
No, the black line is 2 pixels tall. So one pixel black line is above the center line and the other one pixel black line is below the center line. It was created in Photoshop on a 100px grid.wolph42 wrote:edit: i compared your door and this one on the same map next to eachother and noticed that the black line you drew was 1pixel ABOVE the grid, so obviously it disaligns!!
Re: Rotating objects does not align?
I know,but just try this in Maptool.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Rotating objects does not align?
This is very interesting. I'm not a graphics guy (in terms of writing fancy-pants graphics handling code) but I can't think of any reason why a rotated image might not line up.
Each token has a couple of (x,y) coordinates in it for when it's snapped to the grid and when it's not. Those coordinates are interpreted differently when the token is on the Token layer vs. when it's on the Object layer. I'd need to think about this a bit and perhaps work out some of the matrix transforms myself to see what happens to the coordinates when rotating them, but it's certainly a fascinating problem!
I would think that an image with an odd number of pixels (w,h) would rotate more accurately with the pixel in the center sitting still. So when there's an even number of pixels maybe there's some kind of round off error getting in the way? The transforms should be done in double precision arithmetic which I would expect to be plenty accurate enough but maybe that's where the issue lies?
No promises that I'll get this fixed though; I remember digging into that code previously and keeping track of the transforms (in my head) while reading the code got tricky.
Each token has a couple of (x,y) coordinates in it for when it's snapped to the grid and when it's not. Those coordinates are interpreted differently when the token is on the Token layer vs. when it's on the Object layer. I'd need to think about this a bit and perhaps work out some of the matrix transforms myself to see what happens to the coordinates when rotating them, but it's certainly a fascinating problem!
I would think that an image with an odd number of pixels (w,h) would rotate more accurately with the pixel in the center sitting still. So when there's an even number of pixels maybe there's some kind of round off error getting in the way? The transforms should be done in double precision arithmetic which I would expect to be plenty accurate enough but maybe that's where the issue lies?
No promises that I'll get this fixed though; I remember digging into that code previously and keeping track of the transforms (in my head) while reading the code got tricky.
- DreadKatak
- Kobold
- Posts: 12
- Joined: Wed Aug 02, 2017 2:58 am
- Location: Santa Clara, CA
Re: Rotating objects does not align?
I can confirm the same issue as the original poster. Been driving me nuts trying to fix it, but I don't think the issue is with the images.
I also ran into this when trying to get double doors to line up properly.
I also ran into this when trying to get double doors to line up properly.