Shearing + Rotating = distortion?
in
Programming Questions
•
10 months ago
Hello, I'm having trouble with my transformations. I'm trying to make an isometric grid by shearing 30 degrees and then rotating 30 degrees, but it distorts my squares and makes them into rectangles instead of rhombuses. Shearing alone and rotating alone both work how I expect.
This is what it looks like with shearing alone:
This is what it looks like with rotating alone:
This is what it looks like when I shear and then rotate:
Rotating first and then shearing gives a better result, but still wrong:
The vertical is still off. the diagonals aren't perpendicular to each other. (or if they are, they're not horizontal and vertical).
Is this unintuitive behavior the correct behavior? If so, is there a correct series of transformations to use to get me a proper isometric grid? i.e., made up of rhombuses, whose diagonals are vertical and horizontal, with angles of 60 and 120 degrees?
Thanks in advance for the help!
The code is simply this: (i'm using processing.js, which explains the p object)
- p.pushMatrix();
- p.translate(p.width/4, p.height/4);
- p.rotate(p.radians(30));
- p.shearX(p.radians(-30));
- p.rect(0,0,50,50);
- p.popMatrix();
1