0

i'm trying to create navigation mesh on autodesk naviswork using Eyeshot 12.0.113.0 beta.

i'm created region using vertices but result region is very slightly difference.
(i want use Region.Difference() using region.)

why vertices has tiny changed?

example)

public void testFunc()
{
    var test = new List<Point3D>()
    {
        new Point3D(-50, -50, 0),
        new Point3D(-50, 50, 0),
        new Point3D(20.7107, 50, 70.7107),
        new Point3D(20.7107, -50, 70.7107)
    };

    var region = CreateRegion(test);
    region.Regen(0.0);
}

public static Region CreateRegion(List<Point3D> verteses)
{
    var curves = new List<ICurve>();
    for (int i = 1; i < verteses.Count; i++)
    {
        curves.Add(new Line(verteses[i - 1], verteses[i]));
    }
    curves.Add(new Line(verteses.Last(), verteses[0]));
    return new Region(new CompositeCurve(curves, true));
}

i expect the output is :
[0]: {-50, -50, 0}
[1]: {-50, 50, 0}
[2]: {20.7107, 50, 70.7107}
[3]: {20.7107, -50, 70.7107}

but the region.Vertices Result :
[0]: {-50, -50, -2.13163e-14}
[1]: {-50, 50, -3.55271e-15}
[2]: {20.7107, 50, 70.7107}
[3]: {20.7107, -50, 70.7107}

(And region.Plane.Equation is difference too.)

Twily
  • 21
  • 2
  • The exptected output and the results look the same. Have you missed something? – G.Anıl Yalçın Jan 24 '19 at 14:30
  • The values look exactly the same. Floating point number a binary and conversion from decimal to binary can cause slight changes. Try compiling with both Debug and Release mode and see if you get same results. Also try different PCs. The are known bugs in the microprocessors floating point units that are documented on the web. So PC manufactures install driver to patch the issues with the micros. Some of the patches have issues that change results on micros that have good FPUs. – jdweng Jan 24 '19 at 14:34
  • As @jdweng mentioned your issue is the floating point issues. Plus the plane is a matrix and you will most likely never have 2 matrix equal due to floating point issues which are processor architecture related which you cannot fix. You typically need to check for "mostly equal" instead of equal. You can compare if their origins are insanely close and if the angle between their normal vector is very close to 0 degree – Franck Jan 24 '19 at 16:20

1 Answers1

1

Try passing Plane.XY as the second parameter in the Region constructor. Without it, the plane is estimated using a "try-fit-plane" approach and could be different from standard XY.

abenci
  • 8,422
  • 19
  • 69
  • 134