# RandomInstance of GeometricScene producing unexpected result

Consider the following scene as an example:

scene=GeometricScene[{
{"B","P","N","T"},{}
},{
lH==Line[{"B","P"}],
lV==Line[{"B","N"}],
GeometricAssertion[lH,"Horizontal","Leftward"],
GeometricAssertion[lV,"Vertical","Upward"],
GeometricAssertion[{{"P"},{"T"}},{"OppositeSides",lV}],
PlanarAngle[{"T","B","N"},"Counterclockwise"]==12\[Degree],
EuclideanDistance["B","T"]==20,
EuclideanDistance["T","P"]==35
}];

instance=RandomInstance[scene,RandomSeeding->0]


Gives an incorrect scene.

{PlanarAngle[{"P","B","N"}],PlanarAngle[{"P","B","T"}]}/\[Degree]/.instance["Points"]


Produces:

{161.143, 180.}

This is wrong, the expected answer was:

{90., 102.}

Also look at the following scene:

scene=GeometricScene[{
{"NA","NB","NF","A","B","F"},{}
},{
lA==Line[{"A","NA"}],
lB==Line[{"B","NB"}],
lF==Line[{"F","NF"}],
GeometricAssertion[{lA,lB,lF},"Vertical","Upward"],
GeometricAssertion[{{lA},{lB}},{"OppositeSides",lF}],
PlanarAngle[{"NA","A","B"},"Clockwise"]==70\[Degree],
PlanarAngle[{"NA","A","F"},"Clockwise"]==25\[Degree],
PlanarAngle[{"NB","B","F"},"Clockwise"]==345\[Degree],
EuclideanDistance["A","B"]==20.3,
EuclideanDistance["A","NA"]==10,
EuclideanDistance["B","NB"]==10,
EuclideanDistance["F","NF"]==10
}];
instance=RandomInstance[scene,RandomSeeding->0]
{
EuclideanDistance["A","F"],
EuclideanDistance["B","F"]
}/.instance["Points"]//N


{13.6685, 6.78483}

In this scene, the GeometricAssertion on the lines being Upward aligned is ignored by the system. Also EuclideanDistance["A","NA"] is taken to be nearly zero even though I explicitly told it to make it 10.

• Can't reproduce it. The above code produces {90., 102.} in 12.2 on Windows 10 Pro 64 bit. Commented Apr 9, 2021 at 16:10
• With 12.2.0 for Mac OS X x86 (64-bit) I get {161.145, 180.} Commented Apr 9, 2021 at 16:22
• @user64494 are you using Wolfram Desktop or Mathematica? check your release id for the kernel, there are multiple 12.2 versions. Run SystemInformation["Kernel", "ReleaseID"] Commented Apr 9, 2021 at 16:24
• @user13892 - what do you get for EuclideanDistance["B", "N"] /. instance["Points"]? I get basically zero. What if you add the constraint EuclideanDistance["B", "N"] > 1 to your scene? Commented Apr 9, 2021 at 17:19
• @JasonB. Yes it is nearly zero and adding the constraint EuclideanDistance["B", "N"] > 1 does fix the issue. Look at the next example where EuclideanDistance["A","NA"] is ignored. Commented Apr 9, 2021 at 18:27