Exemplo n.º 1
0
        internal static double AreaQuality(Triangle2D triangle)
        {
            double Area = triangle.A.X * triangle.B.Y + triangle.B.X * triangle.C.Y + triangle.C.X * triangle.A.Y - triangle.A.Y * triangle.B.X - triangle.B.Y * triangle.C.X - triangle.C.Y * triangle.A.X;

            Area /= 2;

            return 1 / Math.Abs(Area);
        }
Exemplo n.º 2
0
        public void Union(Triangle2DCollection triangle2DCollection)
        {
            Capacity += triangle2DCollection.Capacity;

            Triangle2D[] triangles = new Triangle2D[Capacity];

            this.Triangles.CopyTo(triangles, 0);
            triangle2DCollection.Triangles.CopyTo(triangles, this.Count);
            this.Triangles = triangles;
            CurrentCount  += triangle2DCollection.Count;
        }
Exemplo n.º 3
0
        internal static double ShapeQuality(Triangle2D triangle)
        {
            //double angle = TriangleQuality(triangle);
            //double Area = triangle.A.X * triangle.B.Y + triangle.B.X * triangle.C.Y + triangle.C.X * triangle.A.Y - triangle.A.Y * triangle.B.X - triangle.B.Y * triangle.C.X - triangle.C.Y * triangle.A.X;

            //Area /= 2;
            //return Math.Exp(2*(angle - Math.PI / 3)) / Math.Abs(Area);

            double val = 0.05 / Math.Max(triangle.AB.Length, Math.Max(triangle.AC.Length, triangle.BC.Length));
            return val;
        }
        public Triangle2DCollection(Triangle2D[] triangles, int capacity)
        {
            Capacity = capacity;
            CurrentCount = triangles.Length;
            if (Capacity < CurrentCount)
            {
                throw (new CollectionCapacityException());
            }

            Triangles = triangles;
        }
Exemplo n.º 5
0
        public static Position GetPosition(Triangle2D a, Triangle2D b)
        {
            int ret = 0;

            if (a.A == b.A || a.A == b.B || a.A == b.C)
            {
                ret++;
            }
            if (a.B == b.A || a.B == b.B || a.B == b.C)
            {
                ret++;
            }
            if (a.C == b.A || a.C == b.B || a.C == b.C)
            {
                ret++;
            }

            return (Position)ret;
        }
Exemplo n.º 6
0
        public void Add(Triangle2D triangle)
        {
            try
            {
                base.Add();
            }
            catch (CollectionCapacityException e)
            {
                string emsg = e.Message;

                this.Capacity *= 2;

                Triangle2D[] triangles = new Triangle2D[Capacity];

                this.Triangles.CopyTo(triangles, 0);
                this.Triangles = triangles;
                base.Add();
            }
            Triangles[CurrentCount - 1] = triangle;
        }
Exemplo n.º 7
0
 public static double TriangleQuality(Triangle2D triangle)
 {
     return Math.Min(triangle.a, Math.Min(triangle.b, triangle.c));
 }
Exemplo n.º 8
0
        private void Triangulation(int a, int b, int c)
        {
            Debug.Assert(a != b && b != c && c != a);

            Triangle2D triangle = new Triangle2D(this.polygon.GetPoint(a), this.polygon.GetPoint(b), this.polygon.GetPoint(c));
            GhostTriangle2D ghost = new GhostTriangle2D(a, b, c);
            this.triangles.Add(triangle);
            this.ghostTriangles.Add(ghost);

            if (lineSegments.Count < polygon.VertexCount - 3)
            {
                Vector2D internalSegment = new Vector2D(a, c);
                LineSegment2D lineSegment = new LineSegment2D(this.polygon.GetPoint(a), this.polygon.GetPoint(c));
                this.lineSegments.Add(lineSegment);
                this.internalSegments.Add(internalSegment);
            }
        }
        public void Add(Triangle2D triangle)
        {
            try
            {
                base.Add();
            }
            catch (CollectionCapacityException e)
            {
                string emsg = e.Message;

                this.Capacity *= 2;

                Triangle2D[] triangles = new Triangle2D[Capacity];

                this.Triangles.CopyTo(triangles, 0);
                this.Triangles = triangles;
                base.Add();
            }
            Triangles[CurrentCount - 1] = triangle;
        }
 public Triangle2DCollection(Triangle2D[] triangles)
 {
     Capacity = triangles.Length;
     Triangles = triangles;
     CurrentCount = Capacity;
 }
        public void Union(Triangle2DCollection triangle2DCollection)
        {
            Capacity += triangle2DCollection.Capacity;

            Triangle2D[] triangles = new Triangle2D[Capacity];

            this.Triangles.CopyTo(triangles, 0);
            triangle2DCollection.Triangles.CopyTo(triangles, this.Count);
            this.Triangles = triangles;
            CurrentCount += triangle2DCollection.Count;
        }