I'm attempting to use FindInstance to generate coordinate sets for plausible triangles with edge length distance constraints. E.g.:
PlaneDimensionXYnm = 1000;
TriangleEdgeDistance = 400;
TriangleSolution = {};
While[Length[TriangleSolution] == 0,
x1 = RandomReal[{200, PlaneDimensionXYnm - 200}];
y1 = RandomReal[{200, PlaneDimensionXYnm - 200}];
TriangleSolution = FindInstance[
EuclideanDistance[{x1, y1}, {x2, y2}] == TriangleEdgeDistance &&
EuclideanDistance[{x1, y1}, {x3, y3}] == TriangleEdgeDistance &&
EuclideanDistance[{x2, y2}, {x3, y3}] == TriangleEdgeDistance &&
x2 >= 200 && y2 >= 200 &&
x3 >= 200 && y3 >= 200 &&
x2 <= PlaneDimensionXYnm - 200 &&
y2 <= PlaneDimensionXYnm - 200 &&
x3 <= PlaneDimensionXYnm - 200 &&
y3 <= PlaneDimensionXYnm - 200, {x2, y2, x3, y3}];
];
TriangleCoordinates = N[{x2, y2, x3, y3} /. TriangleSolution[[1]]];
While the above script works fine (albeit inefficiently, but it doesn't matter for me), the below script fails:
TriangleSolution = {};
TriangleEdgeDistance = 400;
While[Length[TriangleSolution] == 0,
x1 = RandomReal[{200, PlaneDimensionXYnm - 200}];
y1 = RandomReal[{200, PlaneDimensionXYnm - 200}];
TriangleSolution = FindInstance[
EuclideanDistance[{x1, y1}, {x2, y2}] > TriangleEdgeDistance &&
EuclideanDistance[{x1, y1}, {x3, y3}] > TriangleEdgeDistance &&
EuclideanDistance[{x2, y2}, {x3, y3}] > TriangleEdgeDistance &&
x2 >= 200 && y2 >= 200 &&
x3 >= 200 && y3 >= 200 &&
x2 <= PlaneDimensionXYnm - 200 &&
y2 <= PlaneDimensionXYnm - 200 &&
x3 <= PlaneDimensionXYnm - 200 &&
y3 <= PlaneDimensionXYnm - 200, {x2, y2, x3, y3}];
];
TriangleCoordinates = N[{x2, y2, x3, y3} /. TriangleSolution[[1]]];
All I've done here is relax the constraint that the triangle edges should be the same length, and required that the edges all be greater than a certain length. Why does FindInstance now fail?
TriangleEdgeDistance
is not defined. This violates UR1 ("unwritten rule #1), which states "make sure code claimed to work actually does work". $\endgroup$