Is it possible to use a Matrix class to get unrotated dimensions of an object or do I have to do it manually?
$begingroup$
I have an object that has a rotation applied to it and I want to get the pre transformed values.
Here is the dimensions where the element has rotation applied and the dimensions after the rotation is set to none.
Bounds at 90 rotation: {
height 30
width 0
x 25
y 10
}
transform at 90 rotation: matrix(0,1,-1,0,25,10)
set rotation delta: -90
item.rotation: 0
transform at rotation 0: matrix(1,0,0,1,10,25)
Bounds at rotation 0: {
height 0
width 30
x 10
y 25
}
In the past I was able to use an API to set the rotation to 0 and then read the updated bounds. The API has a bug that is preventing using that method so I need to find the dimensions manually.
I have access to a Matrix class and it looks like it has some methods that may help but if not my matrix math is really rusty. Is there an equation I can use to get dimensions at an arbitrary rotation?
Here is the code I have so far:
var bounds = element.bounds;
var rotationDelta = 0 - element.rotation; // -90
var matrix = new Matrix(1, 0, 0, 1, bounds.x, bounds.y); // matrix(1,0,0,1,25,10)
matrix.rotate(rotationDelta); // matrix(0,-1,1,0,25,10)
Calling rotate doesn't change the x or y values or show how to get a transformed width or height.
matrices geometry
$endgroup$
add a comment |
$begingroup$
I have an object that has a rotation applied to it and I want to get the pre transformed values.
Here is the dimensions where the element has rotation applied and the dimensions after the rotation is set to none.
Bounds at 90 rotation: {
height 30
width 0
x 25
y 10
}
transform at 90 rotation: matrix(0,1,-1,0,25,10)
set rotation delta: -90
item.rotation: 0
transform at rotation 0: matrix(1,0,0,1,10,25)
Bounds at rotation 0: {
height 0
width 30
x 10
y 25
}
In the past I was able to use an API to set the rotation to 0 and then read the updated bounds. The API has a bug that is preventing using that method so I need to find the dimensions manually.
I have access to a Matrix class and it looks like it has some methods that may help but if not my matrix math is really rusty. Is there an equation I can use to get dimensions at an arbitrary rotation?
Here is the code I have so far:
var bounds = element.bounds;
var rotationDelta = 0 - element.rotation; // -90
var matrix = new Matrix(1, 0, 0, 1, bounds.x, bounds.y); // matrix(1,0,0,1,25,10)
matrix.rotate(rotationDelta); // matrix(0,-1,1,0,25,10)
Calling rotate doesn't change the x or y values or show how to get a transformed width or height.
matrices geometry
$endgroup$
$begingroup$
Well if the rotation is always $90$ degrees, that's obviously trivial. I assume it isn't, though. Regardless, I don't think this question is appropriate for this site. Not only is it a question about programming, it's not even about a specific library. How can we possibly know if this Matrix class does what you want?
$endgroup$
– Matt Samuel
Jan 7 at 12:17
$begingroup$
I can remove the code. It's about finding out if it's possible to get a size and space in cartesian coordinates space if you have the width height, x y and rotation values. It's probably impossible though so never mind.
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:05
$begingroup$
Rotation by $theta$ is given by $left(begin{array}{ll}cos(theta)&sin(theta)\sin(-theta)&cos(theta)end{array}right)$ I believe, possibly with the sign reversed. It should be easy to find online.
$endgroup$
– Matt Samuel
Jan 7 at 13:07
$begingroup$
I can do a search but what terms would I search for? Yeah, if it was 90' degrees angles it would be done :)
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:08
$begingroup$
The sign is in fact reversed. en.wikipedia.org/wiki/Rotation_matrix
$endgroup$
– Matt Samuel
Jan 7 at 13:09
add a comment |
$begingroup$
I have an object that has a rotation applied to it and I want to get the pre transformed values.
Here is the dimensions where the element has rotation applied and the dimensions after the rotation is set to none.
Bounds at 90 rotation: {
height 30
width 0
x 25
y 10
}
transform at 90 rotation: matrix(0,1,-1,0,25,10)
set rotation delta: -90
item.rotation: 0
transform at rotation 0: matrix(1,0,0,1,10,25)
Bounds at rotation 0: {
height 0
width 30
x 10
y 25
}
In the past I was able to use an API to set the rotation to 0 and then read the updated bounds. The API has a bug that is preventing using that method so I need to find the dimensions manually.
I have access to a Matrix class and it looks like it has some methods that may help but if not my matrix math is really rusty. Is there an equation I can use to get dimensions at an arbitrary rotation?
Here is the code I have so far:
var bounds = element.bounds;
var rotationDelta = 0 - element.rotation; // -90
var matrix = new Matrix(1, 0, 0, 1, bounds.x, bounds.y); // matrix(1,0,0,1,25,10)
matrix.rotate(rotationDelta); // matrix(0,-1,1,0,25,10)
Calling rotate doesn't change the x or y values or show how to get a transformed width or height.
matrices geometry
$endgroup$
I have an object that has a rotation applied to it and I want to get the pre transformed values.
Here is the dimensions where the element has rotation applied and the dimensions after the rotation is set to none.
Bounds at 90 rotation: {
height 30
width 0
x 25
y 10
}
transform at 90 rotation: matrix(0,1,-1,0,25,10)
set rotation delta: -90
item.rotation: 0
transform at rotation 0: matrix(1,0,0,1,10,25)
Bounds at rotation 0: {
height 0
width 30
x 10
y 25
}
In the past I was able to use an API to set the rotation to 0 and then read the updated bounds. The API has a bug that is preventing using that method so I need to find the dimensions manually.
I have access to a Matrix class and it looks like it has some methods that may help but if not my matrix math is really rusty. Is there an equation I can use to get dimensions at an arbitrary rotation?
Here is the code I have so far:
var bounds = element.bounds;
var rotationDelta = 0 - element.rotation; // -90
var matrix = new Matrix(1, 0, 0, 1, bounds.x, bounds.y); // matrix(1,0,0,1,25,10)
matrix.rotate(rotationDelta); // matrix(0,-1,1,0,25,10)
Calling rotate doesn't change the x or y values or show how to get a transformed width or height.
matrices geometry
matrices geometry
asked Jan 7 at 11:27
1.21 gigawatts1.21 gigawatts
14011
14011
$begingroup$
Well if the rotation is always $90$ degrees, that's obviously trivial. I assume it isn't, though. Regardless, I don't think this question is appropriate for this site. Not only is it a question about programming, it's not even about a specific library. How can we possibly know if this Matrix class does what you want?
$endgroup$
– Matt Samuel
Jan 7 at 12:17
$begingroup$
I can remove the code. It's about finding out if it's possible to get a size and space in cartesian coordinates space if you have the width height, x y and rotation values. It's probably impossible though so never mind.
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:05
$begingroup$
Rotation by $theta$ is given by $left(begin{array}{ll}cos(theta)&sin(theta)\sin(-theta)&cos(theta)end{array}right)$ I believe, possibly with the sign reversed. It should be easy to find online.
$endgroup$
– Matt Samuel
Jan 7 at 13:07
$begingroup$
I can do a search but what terms would I search for? Yeah, if it was 90' degrees angles it would be done :)
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:08
$begingroup$
The sign is in fact reversed. en.wikipedia.org/wiki/Rotation_matrix
$endgroup$
– Matt Samuel
Jan 7 at 13:09
add a comment |
$begingroup$
Well if the rotation is always $90$ degrees, that's obviously trivial. I assume it isn't, though. Regardless, I don't think this question is appropriate for this site. Not only is it a question about programming, it's not even about a specific library. How can we possibly know if this Matrix class does what you want?
$endgroup$
– Matt Samuel
Jan 7 at 12:17
$begingroup$
I can remove the code. It's about finding out if it's possible to get a size and space in cartesian coordinates space if you have the width height, x y and rotation values. It's probably impossible though so never mind.
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:05
$begingroup$
Rotation by $theta$ is given by $left(begin{array}{ll}cos(theta)&sin(theta)\sin(-theta)&cos(theta)end{array}right)$ I believe, possibly with the sign reversed. It should be easy to find online.
$endgroup$
– Matt Samuel
Jan 7 at 13:07
$begingroup$
I can do a search but what terms would I search for? Yeah, if it was 90' degrees angles it would be done :)
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:08
$begingroup$
The sign is in fact reversed. en.wikipedia.org/wiki/Rotation_matrix
$endgroup$
– Matt Samuel
Jan 7 at 13:09
$begingroup$
Well if the rotation is always $90$ degrees, that's obviously trivial. I assume it isn't, though. Regardless, I don't think this question is appropriate for this site. Not only is it a question about programming, it's not even about a specific library. How can we possibly know if this Matrix class does what you want?
$endgroup$
– Matt Samuel
Jan 7 at 12:17
$begingroup$
Well if the rotation is always $90$ degrees, that's obviously trivial. I assume it isn't, though. Regardless, I don't think this question is appropriate for this site. Not only is it a question about programming, it's not even about a specific library. How can we possibly know if this Matrix class does what you want?
$endgroup$
– Matt Samuel
Jan 7 at 12:17
$begingroup$
I can remove the code. It's about finding out if it's possible to get a size and space in cartesian coordinates space if you have the width height, x y and rotation values. It's probably impossible though so never mind.
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:05
$begingroup$
I can remove the code. It's about finding out if it's possible to get a size and space in cartesian coordinates space if you have the width height, x y and rotation values. It's probably impossible though so never mind.
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:05
$begingroup$
Rotation by $theta$ is given by $left(begin{array}{ll}cos(theta)&sin(theta)\sin(-theta)&cos(theta)end{array}right)$ I believe, possibly with the sign reversed. It should be easy to find online.
$endgroup$
– Matt Samuel
Jan 7 at 13:07
$begingroup$
Rotation by $theta$ is given by $left(begin{array}{ll}cos(theta)&sin(theta)\sin(-theta)&cos(theta)end{array}right)$ I believe, possibly with the sign reversed. It should be easy to find online.
$endgroup$
– Matt Samuel
Jan 7 at 13:07
$begingroup$
I can do a search but what terms would I search for? Yeah, if it was 90' degrees angles it would be done :)
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:08
$begingroup$
I can do a search but what terms would I search for? Yeah, if it was 90' degrees angles it would be done :)
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:08
$begingroup$
The sign is in fact reversed. en.wikipedia.org/wiki/Rotation_matrix
$endgroup$
– Matt Samuel
Jan 7 at 13:09
$begingroup$
The sign is in fact reversed. en.wikipedia.org/wiki/Rotation_matrix
$endgroup$
– Matt Samuel
Jan 7 at 13:09
add a comment |
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%2f3064899%2fis-it-possible-to-use-a-matrix-class-to-get-unrotated-dimensions-of-an-object-or%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%2f3064899%2fis-it-possible-to-use-a-matrix-class-to-get-unrotated-dimensions-of-an-object-or%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$
Well if the rotation is always $90$ degrees, that's obviously trivial. I assume it isn't, though. Regardless, I don't think this question is appropriate for this site. Not only is it a question about programming, it's not even about a specific library. How can we possibly know if this Matrix class does what you want?
$endgroup$
– Matt Samuel
Jan 7 at 12:17
$begingroup$
I can remove the code. It's about finding out if it's possible to get a size and space in cartesian coordinates space if you have the width height, x y and rotation values. It's probably impossible though so never mind.
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:05
$begingroup$
Rotation by $theta$ is given by $left(begin{array}{ll}cos(theta)&sin(theta)\sin(-theta)&cos(theta)end{array}right)$ I believe, possibly with the sign reversed. It should be easy to find online.
$endgroup$
– Matt Samuel
Jan 7 at 13:07
$begingroup$
I can do a search but what terms would I search for? Yeah, if it was 90' degrees angles it would be done :)
$endgroup$
– 1.21 gigawatts
Jan 7 at 13:08
$begingroup$
The sign is in fact reversed. en.wikipedia.org/wiki/Rotation_matrix
$endgroup$
– Matt Samuel
Jan 7 at 13:09