2:1 Diametric rotation matrix for a 2D orthographic projection
$begingroup$
I asked this question in the game dev stack exchange, but didn't get a response. This is more of a math question with an application in game development so I hope it's alright if I ask here.
I'm trying to implement a 2D isometric game, well diametric with a 2:1 pixel ratio. To do this I have a 2D image of a cube I drew with pixel editing software, where for every pixel up, there are two pixels to the right. I'd like to post an image of it but I don't have the reputation for it. It looks something like this. From what I read this is called dimetric projection, and is composed of two axis rotations, one is 45 degrees about the x axis and the other one is arctan(1/2) around the z. Here is some more detail.
I tried to calculate the rotation matrix, but when I use this to convert an (x,y,z) in Cartesian coordinates to isometric world space coordinates(x`,y`,z`) the cube images do not align correctly with each other, leading me to believe I am missing something else to this problem, or my math is wrong. I have found ways online to fudge it, but they all ignore the z axis which I require. I'm not sure if I did my rotation matrix correctly but here it is:
$$
begin{bmatrix}
1/sqrt{2} & 0 & -1/sqrt(2) \
1sqrt{10} & 2/sqrt{5} & -1/sqrt{10} \
-1sqrt{2/5} & 1/sqrt{5} & sqrt{2/5} \
end{bmatrix}
$$
Edit: I can now upload pictures of what I have working, notice how the images are offset. The blue coordinates are the Cartesian positions before the isometric transformations.
linear-algebra matrices linear-transformations rotations
$endgroup$
|
show 2 more comments
$begingroup$
I asked this question in the game dev stack exchange, but didn't get a response. This is more of a math question with an application in game development so I hope it's alright if I ask here.
I'm trying to implement a 2D isometric game, well diametric with a 2:1 pixel ratio. To do this I have a 2D image of a cube I drew with pixel editing software, where for every pixel up, there are two pixels to the right. I'd like to post an image of it but I don't have the reputation for it. It looks something like this. From what I read this is called dimetric projection, and is composed of two axis rotations, one is 45 degrees about the x axis and the other one is arctan(1/2) around the z. Here is some more detail.
I tried to calculate the rotation matrix, but when I use this to convert an (x,y,z) in Cartesian coordinates to isometric world space coordinates(x`,y`,z`) the cube images do not align correctly with each other, leading me to believe I am missing something else to this problem, or my math is wrong. I have found ways online to fudge it, but they all ignore the z axis which I require. I'm not sure if I did my rotation matrix correctly but here it is:
$$
begin{bmatrix}
1/sqrt{2} & 0 & -1/sqrt(2) \
1sqrt{10} & 2/sqrt{5} & -1/sqrt{10} \
-1sqrt{2/5} & 1/sqrt{5} & sqrt{2/5} \
end{bmatrix}
$$
Edit: I can now upload pictures of what I have working, notice how the images are offset. The blue coordinates are the Cartesian positions before the isometric transformations.
linear-algebra matrices linear-transformations rotations
$endgroup$
$begingroup$
Is your ultimate goal to compute an appropriate projection matrix?
$endgroup$
– amd
Dec 8 '18 at 1:20
$begingroup$
That is correct @amd
$endgroup$
– Ziamor
Dec 8 '18 at 1:26
$begingroup$
Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)?
$endgroup$
– John L Winters
Dec 8 '18 at 1:53
$begingroup$
Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters
$endgroup$
– Ziamor
Dec 8 '18 at 2:34
$begingroup$
Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations.
$endgroup$
– John L Winters
Dec 8 '18 at 3:21
|
show 2 more comments
$begingroup$
I asked this question in the game dev stack exchange, but didn't get a response. This is more of a math question with an application in game development so I hope it's alright if I ask here.
I'm trying to implement a 2D isometric game, well diametric with a 2:1 pixel ratio. To do this I have a 2D image of a cube I drew with pixel editing software, where for every pixel up, there are two pixels to the right. I'd like to post an image of it but I don't have the reputation for it. It looks something like this. From what I read this is called dimetric projection, and is composed of two axis rotations, one is 45 degrees about the x axis and the other one is arctan(1/2) around the z. Here is some more detail.
I tried to calculate the rotation matrix, but when I use this to convert an (x,y,z) in Cartesian coordinates to isometric world space coordinates(x`,y`,z`) the cube images do not align correctly with each other, leading me to believe I am missing something else to this problem, or my math is wrong. I have found ways online to fudge it, but they all ignore the z axis which I require. I'm not sure if I did my rotation matrix correctly but here it is:
$$
begin{bmatrix}
1/sqrt{2} & 0 & -1/sqrt(2) \
1sqrt{10} & 2/sqrt{5} & -1/sqrt{10} \
-1sqrt{2/5} & 1/sqrt{5} & sqrt{2/5} \
end{bmatrix}
$$
Edit: I can now upload pictures of what I have working, notice how the images are offset. The blue coordinates are the Cartesian positions before the isometric transformations.
linear-algebra matrices linear-transformations rotations
$endgroup$
I asked this question in the game dev stack exchange, but didn't get a response. This is more of a math question with an application in game development so I hope it's alright if I ask here.
I'm trying to implement a 2D isometric game, well diametric with a 2:1 pixel ratio. To do this I have a 2D image of a cube I drew with pixel editing software, where for every pixel up, there are two pixels to the right. I'd like to post an image of it but I don't have the reputation for it. It looks something like this. From what I read this is called dimetric projection, and is composed of two axis rotations, one is 45 degrees about the x axis and the other one is arctan(1/2) around the z. Here is some more detail.
I tried to calculate the rotation matrix, but when I use this to convert an (x,y,z) in Cartesian coordinates to isometric world space coordinates(x`,y`,z`) the cube images do not align correctly with each other, leading me to believe I am missing something else to this problem, or my math is wrong. I have found ways online to fudge it, but they all ignore the z axis which I require. I'm not sure if I did my rotation matrix correctly but here it is:
$$
begin{bmatrix}
1/sqrt{2} & 0 & -1/sqrt(2) \
1sqrt{10} & 2/sqrt{5} & -1/sqrt{10} \
-1sqrt{2/5} & 1/sqrt{5} & sqrt{2/5} \
end{bmatrix}
$$
Edit: I can now upload pictures of what I have working, notice how the images are offset. The blue coordinates are the Cartesian positions before the isometric transformations.
linear-algebra matrices linear-transformations rotations
linear-algebra matrices linear-transformations rotations
edited Dec 8 '18 at 2:31
Ziamor
asked Dec 8 '18 at 0:05
ZiamorZiamor
133
133
$begingroup$
Is your ultimate goal to compute an appropriate projection matrix?
$endgroup$
– amd
Dec 8 '18 at 1:20
$begingroup$
That is correct @amd
$endgroup$
– Ziamor
Dec 8 '18 at 1:26
$begingroup$
Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)?
$endgroup$
– John L Winters
Dec 8 '18 at 1:53
$begingroup$
Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters
$endgroup$
– Ziamor
Dec 8 '18 at 2:34
$begingroup$
Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations.
$endgroup$
– John L Winters
Dec 8 '18 at 3:21
|
show 2 more comments
$begingroup$
Is your ultimate goal to compute an appropriate projection matrix?
$endgroup$
– amd
Dec 8 '18 at 1:20
$begingroup$
That is correct @amd
$endgroup$
– Ziamor
Dec 8 '18 at 1:26
$begingroup$
Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)?
$endgroup$
– John L Winters
Dec 8 '18 at 1:53
$begingroup$
Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters
$endgroup$
– Ziamor
Dec 8 '18 at 2:34
$begingroup$
Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations.
$endgroup$
– John L Winters
Dec 8 '18 at 3:21
$begingroup$
Is your ultimate goal to compute an appropriate projection matrix?
$endgroup$
– amd
Dec 8 '18 at 1:20
$begingroup$
Is your ultimate goal to compute an appropriate projection matrix?
$endgroup$
– amd
Dec 8 '18 at 1:20
$begingroup$
That is correct @amd
$endgroup$
– Ziamor
Dec 8 '18 at 1:26
$begingroup$
That is correct @amd
$endgroup$
– Ziamor
Dec 8 '18 at 1:26
$begingroup$
Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)?
$endgroup$
– John L Winters
Dec 8 '18 at 1:53
$begingroup$
Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)?
$endgroup$
– John L Winters
Dec 8 '18 at 1:53
$begingroup$
Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters
$endgroup$
– Ziamor
Dec 8 '18 at 2:34
$begingroup$
Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters
$endgroup$
– Ziamor
Dec 8 '18 at 2:34
$begingroup$
Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations.
$endgroup$
– John L Winters
Dec 8 '18 at 3:21
$begingroup$
Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations.
$endgroup$
– John L Winters
Dec 8 '18 at 3:21
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3030530%2f21-diametric-rotation-matrix-for-a-2d-orthographic-projection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3030530%2f21-diametric-rotation-matrix-for-a-2d-orthographic-projection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Is your ultimate goal to compute an appropriate projection matrix?
$endgroup$
– amd
Dec 8 '18 at 1:20
$begingroup$
That is correct @amd
$endgroup$
– Ziamor
Dec 8 '18 at 1:26
$begingroup$
Can you first scale so the 2 to 1 pixel complication is removed from the problem? Then reformulate based on that? Are you wanting to rotate the cube about its center? Can you express as two successive rotations (factoring)?
$endgroup$
– John L Winters
Dec 8 '18 at 1:53
$begingroup$
Would you be able to elaborate about the scaling first part? I have enough rep now to upload images so I added a picture to help better visualize my problem. The cube also isn't truly a cube, it's an 2D image in 3d space. @JohnLWinters
$endgroup$
– Ziamor
Dec 8 '18 at 2:34
$begingroup$
Yes I voted for your question. Pretend you have a 1 to 1 pixel instead of a 2 to 1 to simplify and focus on the rotations.
$endgroup$
– John L Winters
Dec 8 '18 at 3:21