コード例 #1
0
 private Point3 Interpolate(Point3 point1, Point3 point2, double data1, double data2, double alpha)
 {
     if (data1 < data2)
     {
         return(Point3.Interpolate(alpha, point1, point2));
     }
     else
     {
         return(Point3.Interpolate(alpha, point2, point1));
     }
 }
コード例 #2
0
        public void It_Returns_The_Linear_Interpolation_Between_Two_Points()
        {
            //Arrange
            Point3 p1            = new Point3(0d, 0d, 0d);
            Point3 p2            = new Point3(10d, 10d, 10d);
            Point3 expectedPoint = new Point3(5d, 5d, 5d);
            double amount        = 0.5;

            // Act
            var result = Point3.Interpolate(p1, p2, amount);

            // Assert
            result.Equals(expectedPoint).Should().Be(true);
        }
コード例 #3
0
        public static List <IsoTri> CalcIsoSurface(Mesh m, uint dataIndex, double isoValue, Testing_openTK_again.Del valueToColor, ColorMapControl.ColorMap.Mode mode)
        {
            List <IsoTri> isoTri = new List <IsoTri>();
            //double iso = double.Parse( isoValueText.Text);
            double iso = isoValue;

            foreach (Zone z in m.Zones)
            {
                foreach (Element e in z.Elements)
                {
                    List <double> data = new List <double>();
                    for (int i = 0; i < e.vertInOrder.Length; ++i)
                    {
                        data.Add(z.Vertices[e.vertInOrder[i]].Data[dataIndex]);
                    }

                    var elementCase = ISOSurface.GetElementCase(data.ToArray(), iso);
                    var edges       = ISOSurface.GetCaseEdges(elementCase);
                    for (int i = 0; i < edges.Length; i += 3)
                    {
                        if (edges[i] < 0 || edges[i] > 16)
                        {
                            break;
                        }
                        isoTri.Add(new IsoTri());
                        //triangles.Add(new List<Point3>());
                        for (int j = 0; j < 3; ++j)
                        {
                            var edge      = ISOSurface.GetEdgePoints(edges[i + j]);
                            var startVert = z.Vertices[e.vertInOrder[edge.Start]];
                            var endVert   = z.Vertices[e.vertInOrder[edge.End]];
                            var alpha     = (iso - startVert.Data[dataIndex]) / (endVert.Data[dataIndex] - startVert.Data[dataIndex]);
                            var p         = Point3.Interpolate(alpha, startVert.Position, endVert.Position);
                            //var p = process(iso, startVert.Position, endVert.Position, startVert.Data[dataIndex], startVert.Data[dataIndex]);
                            isoTri[isoTri.Count - 1].triangle.Add(p);
                            Color c = valueToColor(mode, (float)(iso - endVert.Data[dataIndex] + startVert.Data[dataIndex]));
                            isoTri[isoTri.Count - 1].color = new double[] { c.R / 255.0, c.G / 255.0, c.B / 255.0 };
                        }
                    }
                }
            }
            return(isoTri);
        }
コード例 #4
0
 private static Point3 Lerp(Point3 c1, Point3 c2, double t)
 {
     return(Point3.Interpolate(t, c1, c2));
 }