Beispiel #1
0
 private void AppendTrianglesToList(ref LinkedList <Vector3D> list, BoundrySurface.Square s, float z)
 {
     list.AddLast(new Vector3D(s.min.x, s.min.y, z));
     list.AddLast(new Vector3D(s.max.x, s.min.y, z));
     list.AddLast(new Vector3D(s.min.x, s.max.y, z));
     list.AddLast(new Vector3D(s.min.x, s.max.y, z));
     list.AddLast(new Vector3D(s.max.x, s.min.y, z));
     list.AddLast(new Vector3D(s.max.x, s.max.y, z));
 }
Beispiel #2
0
            public bool contains(BoundrySurface.Square sq)
            {
                if (min.x <= (double)sq.min.x && min.y <= (double)sq.min.y && max.x >= (double)sq.max.x)
                {
                    return(max.y >= (double)sq.max.y);
                }

                return(false);
            }
Beispiel #3
0
 public bool intercepts(BoundrySurface.Square sq, out List <BoundrySurface.Square.SegmentIntersection> segmentIntersections)
 {
     segmentIntersections = new List <BoundrySurface.Square.SegmentIntersection>();
     for (var index1 = 0; index1 < Sides.Length; ++index1)
     {
         for (var index2 = 0; index2 < sq.Sides.Length; ++index2)
         {
             if (Sides[index1].intercepts(sq.Sides[index2], out Vector2D? pt))
             {
                 segmentIntersections.Add(new BoundrySurface.Square.SegmentIntersection(index1, pt.Value));
             }
         }
     }
     return((uint)segmentIntersections.Count > 0U);
 }
Beispiel #4
0
        public LinkedList <Vector3D> Generate(Vector2D boxLowerMin, Vector2D boxLowerMax, Vector2D boxUpperMin, Vector2D boxUpperMax, float z)
        {
            var linkedList = (LinkedList <Vector3D>)null;
            var sq1        = new BoundrySurface.Square(boxLowerMin, boxLowerMax);
            var sq2        = new BoundrySurface.Square(boxUpperMin, boxUpperMax);
            var flag1      = sq1.contains(sq2);
            var flag2      = sq2.contains(sq1);

            if (flag1 & flag2 || !flag1 && !flag2)
            {
                return(null);
            }

            if (flag1 | flag2)
            {
                if (flag2)
                {
                    BoundrySurface.Square square = sq1;
                    sq1 = sq2;
                    sq2 = square;
                }
                BoundrySurface.Square[] sqrs = new BoundrySurface.Square[8] {
                    new BoundrySurface.Square(sq1.min, sq2.min), new BoundrySurface.Square(new Vector2D(sq2.min.x, sq2.min.y), new Vector2D(sq2.max.x, sq1.max.y)), new BoundrySurface.Square(new Vector2D(sq2.max.x, sq1.min.y), new Vector2D(sq2.max.x, sq1.min.y)), new BoundrySurface.Square(new Vector2D(sq1.max.x, sq1.min.y), new Vector2D(sq2.max.x, sq1.max.y)), new BoundrySurface.Square(sq1.max, sq2.max), new BoundrySurface.Square(new Vector2D(sq2.min.x, sq2.max.y), new Vector2D(sq2.max.x, sq1.max.y)), new BoundrySurface.Square(new Vector2D(sq1.min.x, sq2.max.y), new Vector2D(sq2.min.x, sq1.max.y)), new BoundrySurface.Square(new Vector2D(sq1.min.x, sq1.max.y), new Vector2D(sq1.min.x, sq2.max.y))
                };
                var list = new LinkedList <Vector3D>();
                AppendTrianglesToList(ref list, sqrs, z);
                return(list);
            }
            if (!sq1.intercepts(sq2, out List <Square.SegmentIntersection> segmentIntersections))
            {
                return(null);
            }

            if (segmentIntersections.Count == 2)
            {
                switch (Math.Abs(segmentIntersections[0].index - segmentIntersections[1].index))
                {
                }
            }
            else
            {
                var count = segmentIntersections.Count;
            }
            return(linkedList);
        }