Unexpected behavior of the procedure `Area` on the object 'Polygon'
$begingroup$
Sometimes get a results, sometimes left unevaluated.
For instance
Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
12
Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
(a,b - some 2x2 matrices)
Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )
Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]
Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
(copy and paste)
1440
How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?
bugs evaluation computational-geometry polygons packed-arrays
$endgroup$
add a comment |
$begingroup$
Sometimes get a results, sometimes left unevaluated.
For instance
Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
12
Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
(a,b - some 2x2 matrices)
Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )
Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]
Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
(copy and paste)
1440
How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?
bugs evaluation computational-geometry polygons packed-arrays
$endgroup$
3
$begingroup$
What are the definitions ofa
andb
?
$endgroup$
– MarcoB
13 hours ago
$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like hisa.b == {{2,7},{-16,4}}
This seems to reproduce his results.
$endgroup$
– Bill
12 hours ago
add a comment |
$begingroup$
Sometimes get a results, sometimes left unevaluated.
For instance
Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
12
Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
(a,b - some 2x2 matrices)
Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )
Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]
Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
(copy and paste)
1440
How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?
bugs evaluation computational-geometry polygons packed-arrays
$endgroup$
Sometimes get a results, sometimes left unevaluated.
For instance
Area@Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
12
Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
(a,b - some 2x2 matrices)
Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
Area@(Transpose@(a.b.Transpose[#]) & /@ Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}] )
Area[Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]]
Area@Polygon[{{0, 0}, {8, -64}, {18, -24}, {36, -48}, {28, 16}}]
(copy and paste)
1440
How to guess when a calculation will give a result and when it will not be evaluated? And why does it not evaluate?
bugs evaluation computational-geometry polygons packed-arrays
bugs evaluation computational-geometry polygons packed-arrays
edited 11 hours ago
kirma
10.2k13058
10.2k13058
asked 14 hours ago
Slepecky MamutSlepecky Mamut
618110
618110
3
$begingroup$
What are the definitions ofa
andb
?
$endgroup$
– MarcoB
13 hours ago
$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like hisa.b == {{2,7},{-16,4}}
This seems to reproduce his results.
$endgroup$
– Bill
12 hours ago
add a comment |
3
$begingroup$
What are the definitions ofa
andb
?
$endgroup$
– MarcoB
13 hours ago
$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like hisa.b == {{2,7},{-16,4}}
This seems to reproduce his results.
$endgroup$
– Bill
12 hours ago
3
3
$begingroup$
What are the definitions of
a
and b
?$endgroup$
– MarcoB
13 hours ago
$begingroup$
What are the definitions of
a
and b
?$endgroup$
– MarcoB
13 hours ago
$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like his
a.b == {{2,7},{-16,4}}
This seems to reproduce his results.$endgroup$
– Bill
12 hours ago
$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like his
a.b == {{2,7},{-16,4}}
This seems to reproduce his results.$endgroup$
– Bill
12 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)
Seems like a bug in my opinion. Consider the following:
With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]},
With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
{poly0 === poly, Area /@ {poly0, poly}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
Although the Mma considers poly0
and its transformed but identical copy (coordinates transformed using IdentityMatrix
) identical, they produce different results.
Probably the internal representation of poly
is not the same as poly0
. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.
This can be further simplified to show that from the perspective of Polygon
two semantically identical coordinate lists can differ:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
I suspect there's something wrong with the way Polygon
reads the internal representation of a list!
EDIT: I think there's a good chance this problem is caused by the fact coord
is a packed array, while coord0
is not:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]
{True, {False, True}, {12, 12}}
So, you can use FromPackedArray
on the transformed coordinate list as a workaround.
$endgroup$
add a comment |
$begingroup$
This is a packed array issue:
Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]
This will be fixed in M12.
$endgroup$
add a comment |
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: "387"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
},
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%2fmathematica.stackexchange.com%2fquestions%2f193772%2funexpected-behavior-of-the-procedure-area-on-the-object-polygon%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)
Seems like a bug in my opinion. Consider the following:
With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]},
With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
{poly0 === poly, Area /@ {poly0, poly}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
Although the Mma considers poly0
and its transformed but identical copy (coordinates transformed using IdentityMatrix
) identical, they produce different results.
Probably the internal representation of poly
is not the same as poly0
. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.
This can be further simplified to show that from the perspective of Polygon
two semantically identical coordinate lists can differ:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
I suspect there's something wrong with the way Polygon
reads the internal representation of a list!
EDIT: I think there's a good chance this problem is caused by the fact coord
is a packed array, while coord0
is not:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]
{True, {False, True}, {12, 12}}
So, you can use FromPackedArray
on the transformed coordinate list as a workaround.
$endgroup$
add a comment |
$begingroup$
EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)
Seems like a bug in my opinion. Consider the following:
With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]},
With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
{poly0 === poly, Area /@ {poly0, poly}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
Although the Mma considers poly0
and its transformed but identical copy (coordinates transformed using IdentityMatrix
) identical, they produce different results.
Probably the internal representation of poly
is not the same as poly0
. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.
This can be further simplified to show that from the perspective of Polygon
two semantically identical coordinate lists can differ:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
I suspect there's something wrong with the way Polygon
reads the internal representation of a list!
EDIT: I think there's a good chance this problem is caused by the fact coord
is a packed array, while coord0
is not:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]
{True, {False, True}, {12, 12}}
So, you can use FromPackedArray
on the transformed coordinate list as a workaround.
$endgroup$
add a comment |
$begingroup$
EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)
Seems like a bug in my opinion. Consider the following:
With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]},
With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
{poly0 === poly, Area /@ {poly0, poly}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
Although the Mma considers poly0
and its transformed but identical copy (coordinates transformed using IdentityMatrix
) identical, they produce different results.
Probably the internal representation of poly
is not the same as poly0
. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.
This can be further simplified to show that from the perspective of Polygon
two semantically identical coordinate lists can differ:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
I suspect there's something wrong with the way Polygon
reads the internal representation of a list!
EDIT: I think there's a good chance this problem is caused by the fact coord
is a packed array, while coord0
is not:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]
{True, {False, True}, {12, 12}}
So, you can use FromPackedArray
on the transformed coordinate list as a workaround.
$endgroup$
EDIT: Reported to WRI as CASE:4237867 - and apparently should work on V12. :)
Seems like a bug in my opinion. Consider the following:
With[{poly0 = Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]},
With[{poly = Transpose[IdentityMatrix[2].Transpose@#] & /@ poly0},
{poly0 === poly, Area /@ {poly0, poly}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
Although the Mma considers poly0
and its transformed but identical copy (coordinates transformed using IdentityMatrix
) identical, they produce different results.
Probably the internal representation of poly
is not the same as poly0
. At the same time its output form is identical, which actually transforms it to other form if you copy and paste it.
This can be further simplified to show that from the perspective of Polygon
two semantically identical coordinate lists can differ:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Area@*Polygon /@ {coord0, coord}}]]
{True, {12, Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]}}
I suspect there's something wrong with the way Polygon
reads the internal representation of a list!
EDIT: I think there's a good chance this problem is caused by the fact coord
is a packed array, while coord0
is not:
With[{coord0 = {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}},
With[{coord = Transpose[IdentityMatrix[2].Transpose@coord0]},
{coord0 === coord, Developer`PackedArrayQ /@ {coord0, coord},
Area@*Polygon /@ {coord0, Developer`FromPackedArray@coord}}]]
{True, {False, True}, {12, 12}}
So, you can use FromPackedArray
on the transformed coordinate list as a workaround.
edited 11 hours ago
answered 12 hours ago
kirmakirma
10.2k13058
10.2k13058
add a comment |
add a comment |
$begingroup$
This is a packed array issue:
Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]
This will be fixed in M12.
$endgroup$
add a comment |
$begingroup$
This is a packed array issue:
Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]
This will be fixed in M12.
$endgroup$
add a comment |
$begingroup$
This is a packed array issue:
Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]
This will be fixed in M12.
$endgroup$
This is a packed array issue:
Area @ Polygon[Developer`ToPackedArray @ {{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]
Area[Polygon[{{0, 0}, {4, 0}, {2, 2}, {4, 4}, {0, 4}}]]
This will be fixed in M12.
answered 11 hours ago
Carl WollCarl Woll
71.2k394185
71.2k394185
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica 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%2fmathematica.stackexchange.com%2fquestions%2f193772%2funexpected-behavior-of-the-procedure-area-on-the-object-polygon%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
3
$begingroup$
What are the definitions of
a
andb
?$endgroup$
– MarcoB
13 hours ago
$begingroup$
If you want to experiment with this and I haven't made a mistake then it looks like his
a.b == {{2,7},{-16,4}}
This seems to reproduce his results.$endgroup$
– Bill
12 hours ago