コード例 #1
0
        public double GetEdgeLength(TetrahedronEdge edge)
        {
            Point3D point0 = GetPoint(edge, true);
            Point3D point1 = GetPoint(edge, false);

            return((point1 - point0).Length);
        }
コード例 #2
0
        public Point3D GetCommonPoint(TetrahedronEdge edge0, TetrahedronEdge edge1)
        {
            Point3D[] points0 = new Point3D[] { GetPoint(edge0, true), GetPoint(edge0, false) };
            Point3D[] points1 = new Point3D[] { GetPoint(edge1, true), GetPoint(edge1, false) };

            // Find exact
            for (int cntr0 = 0; cntr0 < points0.Length; cntr0++)
            {
                for (int cntr1 = 0; cntr1 < points1.Length; cntr1++)
                {
                    if (points0[cntr0] == points1[cntr1])
                    {
                        return(points0[cntr0]);
                    }
                }
            }

            // Find close - execution should never get here, just being safe
            for (int cntr0 = 0; cntr0 < points0.Length; cntr0++)
            {
                for (int cntr1 = 0; cntr1 < points1.Length; cntr1++)
                {
                    if (Math3D.IsNearValue(points0[cntr0], points1[cntr1]))
                    {
                        return(points0[cntr0]);
                    }
                }
            }

            throw new ApplicationException("Didn't find a common point");
        }
コード例 #3
0
        public Point3D GetEdgeMidpoint(TetrahedronEdge edge)
        {
            Point3D point0 = GetPoint(edge, true);
            Point3D point1 = GetPoint(edge, false);

            Vector3D halfLength = (point1 - point0) * .5d;

            return(point0 + halfLength);
        }
コード例 #4
0
        public int GetCommonIndex(TetrahedronEdge edge0, TetrahedronEdge edge1)
        {
            int[] indices0 = new int[] { this.GetIndex(edge0, true), this.GetIndex(edge0, false) };
            int[] indices1 = new int[] { this.GetIndex(edge1, true), this.GetIndex(edge1, false) };

            for (int cntr0 = 0; cntr0 < indices0.Length; cntr0++)
            {
                for (int cntr1 = 0; cntr1 < indices1.Length; cntr1++)
                {
                    if (indices0[cntr0] == indices1[cntr1])
                    {
                        return(indices0[cntr0]);
                    }
                }
            }

            throw new ApplicationException("Didn't find a common index");
        }
コード例 #5
0
        public int GetIndex(TetrahedronEdge edge, bool isFrom)
        {
            switch (edge)
            {
            case TetrahedronEdge.Edge_01:
                if (isFrom)
                {
                    return(this.Index0);
                }
                else
                {
                    return(this.Index1);
                }

            case TetrahedronEdge.Edge_02:
                if (isFrom)
                {
                    return(this.Index0);
                }
                else
                {
                    return(this.Index2);
                }

            case TetrahedronEdge.Edge_03:
                if (isFrom)
                {
                    return(this.Index0);
                }
                else
                {
                    return(this.Index3);
                }

            case TetrahedronEdge.Edge_12:
                if (isFrom)
                {
                    return(this.Index1);
                }
                else
                {
                    return(this.Index2);
                }

            case TetrahedronEdge.Edge_13:
                if (isFrom)
                {
                    return(this.Index1);
                }
                else
                {
                    return(this.Index3);
                }

            case TetrahedronEdge.Edge_23:
                if (isFrom)
                {
                    return(this.Index2);
                }
                else
                {
                    return(this.Index3);
                }

            default:
                throw new ApplicationException("Unknown TetrahedronEdge: " + edge.ToString());
            }
        }
コード例 #6
0
        public Point3D GetPoint(TetrahedronEdge edge, bool isFrom)
        {
            switch (edge)
            {
            case TetrahedronEdge.Edge_01:
                if (isFrom)
                {
                    return(this.AllPoints[this.Index0]);
                }
                else
                {
                    return(this.AllPoints[this.Index1]);
                }

            case TetrahedronEdge.Edge_02:
                if (isFrom)
                {
                    return(this.AllPoints[this.Index0]);
                }
                else
                {
                    return(this.AllPoints[this.Index2]);
                }

            case TetrahedronEdge.Edge_03:
                if (isFrom)
                {
                    return(this.AllPoints[this.Index0]);
                }
                else
                {
                    return(this.AllPoints[this.Index3]);
                }

            case TetrahedronEdge.Edge_12:
                if (isFrom)
                {
                    return(this.AllPoints[this.Index1]);
                }
                else
                {
                    return(this.AllPoints[this.Index2]);
                }

            case TetrahedronEdge.Edge_13:
                if (isFrom)
                {
                    return(this.AllPoints[this.Index1]);
                }
                else
                {
                    return(this.AllPoints[this.Index3]);
                }

            case TetrahedronEdge.Edge_23:
                if (isFrom)
                {
                    return(this.AllPoints[this.Index2]);
                }
                else
                {
                    return(this.AllPoints[this.Index3]);
                }

            default:
                throw new ApplicationException("Unknown TetrahedronEdge: " + edge.ToString());
            }
        }