Ejemplo n.º 1
0
        public void Test_XYZTests_GetTriangleHeightExWrong()
        {
            //GetTriangleHeight and GetTriangleHeightEx should return the same result. The latter is an optimized version of the former.

            var v0 = new XYZ(947908.950000, 367225.330000, 1652.360962);
            var v1 = new XYZ(947904.870000, 367219.890000, 1652.048950);
            var v2 = new XYZ(947913.370000, 367217.510000, 1653.223999);
            var x  = 947909.29000000015;
            var y  = 367221.93;
            var z  = 1652.5344904049828;

            Assert.Equal(z, XYZ.GetTriangleHeight(v0, v1, v2, x, y));
            //Currently GetTriangleHeightEx returns 1652.749808195186
            Assert.Equal(z, XYZ.GetTriangleHeightEx(ref v0, ref v1, ref v2, x, y));
        }
Ejemplo n.º 2
0
        private void AddEndIntercept(XYZ point, List <XYZS> intercepts, double station)
        {
            if (!Index.CalculateIndexOfCellContainingPosition(point.X, point.Y, out int cellX, out int cellY))
            {
                Log.LogWarning($"No cell address computable for end point location {point.X}:{point.Y}");
                return;
            }

            var subGrid = Index.LocateSubGridContaining(cellX, cellY);

            if (subGrid == null) // No triangles in this 'node' sub grid
            {
                return;
            }

            if (!(subGrid is TriangleArrayReferenceSubGrid referenceSubGrid))
            {
                Log.LogCritical($"Sub grid is not a TriangleArrayReferenceSubGrid, is is a {subGrid.GetType()}");
                return;
            }

            // Get the cell representing a leaf sub grid and determine if there is a triangle at the point location
            subGrid.GetSubGridCellIndex(cellX, cellY, out byte subGridX, out byte subGridY);

            TriangleArrayReference referenceList = referenceSubGrid.Items[subGridX, subGridY];

            int endIndex = referenceList.TriangleArrayIndex + referenceList.Count;

            for (int i = referenceList.TriangleArrayIndex; i < endIndex; i++)
            {
                double height = XYZ.GetTriangleHeightEx
                                    (ref TTM.Vertices.Items[TTM.Triangles.Items[Indices[i]].Vertex0],
                                    ref TTM.Vertices.Items[TTM.Triangles.Items[Indices[i]].Vertex1],
                                    ref TTM.Vertices.Items[TTM.Triangles.Items[Indices[i]].Vertex2], point.X, point.Y);

                if (height != Common.Consts.NullDouble)
                {
                    intercepts.Add(new XYZS(point.X, point.Y, height, station, Indices[i]));
                    return;
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Determine the elevation on the triangle at the location given by x and y. If the location is not
 /// within the triangle this will return Consts.NullDouble
 /// </summary>
 public double InterpolateHeight(double x, double y) => XYZ.GetTriangleHeightEx(ref V1, ref V2, ref V3, x, y);
Ejemplo n.º 4
0
 private double GetHeight2(ref Triangle tri, double X, double Y)
 {
     return(XYZ.GetTriangleHeightEx(ref vertexItems[tri.Vertex0], ref vertexItems[tri.Vertex1], ref vertexItems[tri.Vertex2], X, Y));
 }