Is there an intuitive and rational way to automatically convert ranges into coordinates?
An alternative, and to get them in clock wise order, is to use Outer
product, something like
canonicalizePolygon[{x1_, y1_}, {x2_, y2_}] := Module[{coord},
coord = Outer[List, {x1, x2}, {y1, y2}];
coord[[2]] = Reverse[coord[[2]]];
Flatten[coord, 1]
];
Call it as
canonicalizePolygon[{x1, y1}, {x2, y2}]
For a cubiod
, same thing, find coordinates of corners for the front face rectangle, and then find coordinates of corners for the back face rectangle.
For other shapes, I think it will have to be case by case.
Perhaps I didn't get the purpose of your question/application…
The function CanonicalizePolygon
helps to find the 4 points of Rectangle[{x1,y1},{x2,y2}]
CanonicalizePolygon[Rectangle[ {x1, y1}, {x2, y2} ]][[ 1]]
(*{{x1, y1}, {x1, y2}, {x2, y1}, {x2, y2}}*)
or with assumptions
CanonicalizePolygon[Rectangle[ {x1, y1}, {x2, y2} ],Assumptions -> {x2 > x1, y2 > y1 }][[ 1]]
(*{{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}}*)
ClearAll[x];
n = 2;
Tuples@Array[x, {n, 2}]
{{x[1, 1], x[2, 1]}, {x[1, 1], x[2, 2]}, {x[1, 2], x[2, 1]}, {x[1, 2], x[2, 2]}}
3D:
ClearAll[x];
n = 3;
Tuples@Array[x, {n, 2}]
{{x[1, 1], x[2, 1], x[3, 1]}, {x[1, 1], x[2, 1], x[3, 2]}, {x[1, 1], x[2, 2], x[3, 1]}, {x[1, 1], x[2, 2], x[3, 2]}, {x[1, 2], x[2, 1], x[3, 1]}, {x[1, 2], x[2, 1], x[3, 2]}, {x[1, 2], x[2, 2], x[3, 1]}, {x[1, 2], x[2, 2], x[3, 2]}}
or
x = {x1, y1};
y = {x2, y2};
z = {x3, y3};
Tuples[{x, y, z}]
{{x1, x2, x3}, {x1, x2, y3}, {x1, y2, x3}, {x1, y2, y3}, {y1, x2, x3}, {y1, x2, y3}, {y1, y2, x3}, {y1, y2, y3}}