public MinkowskiDifference(IShape2D shapeA, Transform2D transformA, IShape2D shapeB, Transform2D transformB)
 {
     ShapeA     = shapeA;
     TransformA = transformA;
     ShapeB     = shapeB;
     TransformB = transformB;
 }
Exemplo n.º 2
0
        public static Bounds2D GetBounds(IShape2D shape, Matrix4D transformation)
        {
            Bounds2D bounds = new Bounds2D();

            ShapeTool.AddToBounds(bounds, shape.CreateIterator(), transformation);
            return(bounds);
        }
Exemplo n.º 3
0
        public static Bounds2D GetBounds(IShape2D shape)
        {
            Bounds2D bounds = new Bounds2D();

            shape.AddToBounds(bounds);
            return(bounds);
        }
Exemplo n.º 4
0
        public Vector3[] GetVectors(IShape2D shape)
        {
            RectangleF r  = shape.Bounds;
            float      x0 = -0.5f * dxy;
            float      y0 = x0 * (n - 0x01);

            x0 *= (m - 0x01);
            double          dxyinv = 1.0d / this.dxy;
            int             xi1 = Math.Max(0x00, Math.Min(n - 0x01, (int)Math.Floor((r.X - x0) * dxyinv)));
            int             xi2 = Math.Max(0x00, Math.Min(n - 0x01, (int)Math.Ceiling((r.Right - x0) * dxyinv)));
            int             yi1 = Math.Max(0x00, Math.Min(m - 0x01, (int)Math.Floor((r.Y - y0) * dxyinv)));
            int             yi2 = Math.Max(0x00, Math.Min(m - 0x01, (int)Math.Ceiling((r.Bottom - y0) * dxyinv)));
            int             dx = xi2 - xi1;
            int             dxa = n - dx - 0x01;
            int             k = yi1 * n + xi1, K;
            Vector3         v;
            Stack <Vector3> vs = new Stack <Vector3>();

            for (int y = yi1; y <= yi2; y++)
            {
                for (K = k + dx; k <= K; k++)
                {
                    v = PosNor[k];
                    if (shape.Contains(v.X, v.Z))
                    {
                        vs.Push(v);
                    }
                }
                k += dxa;
            }
            return(vs.ToArray());
        }
Exemplo n.º 5
0
 public BoundingBox2D(IShape2D obj, Point2D topLeft)
 {
     shape = obj;
     TopLeft = topLeft;
     Width = obj.GetWidth();
     Height = obj.GetHeight();
 }
Exemplo n.º 6
0
 public Collider(IShape2D colliderShape)
 {
     shape                 = colliderShape;
     OnCollisionEnter     += AddNewIntersectingCollider;
     OnCollisionExit      += RemoveIntersectingCollider;
     IntersectingColliders = new List <Collider>();
 }
Exemplo n.º 7
0
 public Class866(char letter, IShape2D path, Vector2D advance, bool filled)
 {
     this.vector2D_0 = advance;
     this.char_0     = letter;
     this.ishape2D_0 = path ?? ShapeTool.NullShape;
     this.bool_0     = filled;
 }
Exemplo n.º 8
0
 public Vector3[] GetVectors(IShape2D shape)
 {
     RectangleF r = shape.Bounds;
     float x0 = -0.5f*dxy;
     float y0 = x0*(n-0x01);
     x0 *= (m-0x01);
     double dxyinv = 1.0d/this.dxy;
     int xi1 = Math.Max(0x00,Math.Min(n-0x01,(int) Math.Floor((r.X-x0)*dxyinv)));
     int xi2 = Math.Max(0x00,Math.Min(n-0x01,(int) Math.Ceiling((r.Right-x0)*dxyinv)));
     int yi1 = Math.Max(0x00,Math.Min(m-0x01,(int) Math.Floor((r.Y-y0)*dxyinv)));
     int yi2 = Math.Max(0x00,Math.Min(m-0x01,(int) Math.Ceiling((r.Bottom-y0)*dxyinv)));
     int dx = xi2-xi1;
     int dxa = n-dx-0x01;
     int k = yi1*n+xi1, K;
     Vector3 v;
     Stack<Vector3> vs = new Stack<Vector3>();
     for(int y = yi1; y <= yi2; y++) {
         for(K = k+dx; k <= K; k++) {
             v = PosNor[k];
             if(shape.Contains(v.X,v.Z)) {
                 vs.Push(v);
             }
         }
         k += dxa;
     }
     return vs.ToArray();
 }
Exemplo n.º 9
0
        private static Vector2 GenerateDartInShapeBounds(IShape2D shape)
        {
            double randW = ThreadSafeRandom.Next() * (shape.MaxX - shape.MinX) + shape.MinX;
            double randH = ThreadSafeRandom.Next() * (shape.MaxY - shape.MinY) + shape.MinY;
            var    dart  = new Vector2(randW, randH);

            return(dart);
        }
Exemplo n.º 10
0
 public static bool AreEqual(IShape2D shape1, IShape2D shape2)
 {
     if (shape1 == shape2)
     {
         return(true);
     }
     return(ShapeTool.smethod_1(shape1.CreateIterator(), shape2.CreateIterator()));
 }
Exemplo n.º 11
0
 public void DrawCharPath(
     IShape2D path,
     Matrix4D transform,
     Color color,
     short lineWeight,
     bool filled,
     double extrusion)
 {
     this.method_0(path, color, transform, filled, extrusion, true);
 }
Exemplo n.º 12
0
 public CachedBoundsShape2D(IShape2D wrappedShape)
 {
     this.ishape2D_0 = wrappedShape;
     this.bounds2D_0 = new Bounds2D();
     wrappedShape.AddToBounds(this.bounds2D_0);
     if (this.bounds2D_0.Initialized)
     {
         return;
     }
     this.bounds2D_0 = (Bounds2D)null;
 }
Exemplo n.º 13
0
        public void DrawCharPath(
            IShape2D path,
            Matrix4D transform,
            Color color,
            short lineWeight,
            bool filled,
            double extrusion)
        {
            IShape4D shape = (IShape4D) new FlatShape4D(path, filled);

            shape.Transform(transform);
            this.ipathDrawer_0.DrawCharPath(this.iclippingTransformer_0.Transform(shape).ToShape2D(Matrix4D.Identity), Matrix4D.Identity, color, lineWeight, filled, extrusion);
        }
Exemplo n.º 14
0
        public static FillableShape2D ToFillableShape(IShape2D shape, bool filled)
        {
            FillableShape2D fillableShape2D = shape as FillableShape2D;

            if (fillableShape2D == null)
            {
                return(new FillableShape2D(shape, filled));
            }
            if (fillableShape2D.Filled != filled)
            {
                return(new FillableShape2D(fillableShape2D.ishape2D_0, filled));
            }
            return(fillableShape2D);
        }
Exemplo n.º 15
0
        internal Class454 method_0(IShape2D shape, GraphicsConfig config)
        {
            Struct13 key = new Struct13(shape, config.ShapeFlattenEpsilon);
            Class454 class454_1;

            if (this.dictionary_0.TryGetValue(key, out class454_1))
            {
                return(class454_1);
            }
            Class454 class454_2 = new Class454(shape, config);

            this.dictionary_0.Add(key, class454_2);
            return(class454_2);
        }
Exemplo n.º 16
0
 public bool Intersects(IShape2D other, bool doubledsided = true)
 {
     if (other is Rect rectangle)
     {
         return(this.Intersects(rectangle));
     }
     else if (doubledsided)
     {
         return(other.Intersects(this, false));
     }
     else
     {
         throw new ArgumentException();
     }
 }
Exemplo n.º 17
0
        public Interface34 GetText(
            string text,
            WW.Cad.Model.Color color,
            short lineWeight,
            bool vertical)
        {
            GeneralShape2D generalShape2D;

            using (GraphicsPath graphicsPath = this.class26_0.method_1(text))
                generalShape2D = (GeneralShape2D)graphicsPath;
            generalShape2D.FillMode = WW.Math.Geometry.FillMode.Winding;
            IShape2D path = generalShape2D.HasSegments ? (IShape2D) new CachedBoundsShape2D((IShape2D)generalShape2D) : (IShape2D)NullShape2D.Instance;

            return((Interface34) new Class865(text, (Interface14)this, color, lineWeight, path, this.class26_0.CharTransformation, Transformation2D.Scaling(this.class26_0.CanonicalScaling), this.class26_0.imethod_0(text, (IList <Vector2D>)null)));
        }
Exemplo n.º 18
0
        public void DrawPath(
            IShape2D path,
            Matrix4D transform,
            Color color,
            short lineWeight,
            bool filled,
            bool forText,
            double extrusion)
        {
            if (!path.HasSegments)
            {
                return;
            }
            IClippingTransformer transformer = (IClippingTransformer)this.wireframe_0.GetTransformer().Clone();

            transformer.SetPreTransform(transform);
            IWireframeGraphicsFactory graphicsFactory0 = this.iwireframeGraphicsFactory_0;

            if (extrusion == 0.0)
            {
                IShape4D shape1 = (IShape4D) new FlatShape4D((IShape2D)(path as GeneralShape2D ?? new GeneralShape2D(path, true)), filled);
                IShape4D shape2 = transformer.Transform(shape1);
                if (shape2.IsEmpty)
                {
                    return;
                }
                graphicsFactory0.CreateShape(this.dxfEntity_0, this.wireframe_0, this.wireframe_0.GetPlotColor(this.dxfEntity_0, color), forText, shape2);
            }
            else
            {
                IList <Polyline2D> flattened  = (IList <Polyline2D>)ShapeTool.GetFlattened(path, this.wireframe_0.Config.ShapeFlattenEpsilon);
                IList <Polyline4D> polylines1 = DxfUtil.smethod_39(flattened, filled, transformer);
                ArgbColor          plotColor  = this.wireframe_0.GetPlotColor(this.dxfEntity_0, color);
                graphicsFactory0.CreatePathAsOne(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polylines1, false, true);
                transformer.SetPreTransform(Transformation4D.Translation(0.0, 0.0, extrusion));
                IList <Polyline4D> polylines2 = DxfUtil.smethod_39(flattened, filled, transformer);
                graphicsFactory0.CreatePathAsOne(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polylines2, false, true);
                for (int index1 = polylines1.Count - 1; index1 >= 0; --index1)
                {
                    Polyline4D polyline4D1 = polylines1[index1];
                    Polyline4D polyline4D2 = polylines2[index1];
                    for (int index2 = polyline4D1.Count - 1; index2 >= 0; --index2)
                    {
                        graphicsFactory0.CreateLine(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polyline4D1[index2], polyline4D2[index2]);
                    }
                }
            }
        }
Exemplo n.º 19
0
        private static OverlapInformation CalculateOverlap(IShape2D a, IShape2D b)
        {
            LineSegment edge       = new LineSegment(0, 0, 0, 0);
            float       minOverlap = float.MaxValue;

            for (int i = 0; i < a.Edges.Length; i++)
            {
                Vector2 normal = new Vector2(
                    -(a.Edges[i].Y2 - a.Edges[i].Y1),
                    a.Edges[i].X2 - a.Edges[i].X1
                    );

                float minProjectionA = Vector2.Dot(a.Vertices[0], normal);
                float maxProjectionA = minProjectionA;

                for (int j = 1; j < a.Vertices.Length; j++)
                {
                    float projection = Vector2.Dot(a.Vertices[j], normal);
                    minProjectionA = Math.Min(minProjectionA, projection);
                    maxProjectionA = Math.Max(maxProjectionA, projection);
                }

                float minProjectionB = Vector2.Dot(b.Vertices[0], normal);
                float maxProjectionB = minProjectionB;

                for (int j = 1; j < b.Vertices.Length; j++)
                {
                    float projection = Vector2.Dot(b.Vertices[j], normal);
                    minProjectionB = Math.Min(minProjectionB, projection);
                    maxProjectionB = Math.Max(maxProjectionB, projection);
                }

                float overlap = Math.Min(maxProjectionA, maxProjectionB) - Math.Max(minProjectionA, minProjectionB);

                if (overlap < minOverlap)
                {
                    minOverlap = overlap;
                    edge       = a.Edges[i];
                }

                if (maxProjectionB < minProjectionA || maxProjectionA < minProjectionB)
                {
                    return(new OverlapInformation(new LineSegment(), -1, false));
                }
            }

            return(new OverlapInformation(edge, minOverlap, true));
        }
Exemplo n.º 20
0
        public Class521(ShxFile font, ShxShape shape, GraphicsConfig graphicsConfig)
        {
            this.int_0 = font.Above;
            Point2D  endPoint;
            IShape2D glyphShape = shape.GetGlyphShape(false, out endPoint);

            this.vector2D_0 = (Vector2D)endPoint;
            this.ilist_0    = (IList <Polyline2D>)ShapeTool.GetFlattened(glyphShape, graphicsConfig.ShapeFlattenEpsilon);
            foreach (List <Point2D> point2DList in (IEnumerable <Polyline2D>) this.ilist_0)
            {
                foreach (Point2D p in point2DList)
                {
                    this.bounds2D_0.Update(p);
                }
            }
        }
Exemplo n.º 21
0
 public void method_4(IShape2D lining)
 {
     if (this.ishape2D_1 == null)
     {
         this.ishape2D_1 = new IShape2D[1] {
             lining
         };
     }
     else
     {
         IShape2D[] shape2DArray = new IShape2D[this.ishape2D_1.Length + 1];
         Array.Copy((Array)this.ishape2D_1, (Array)shape2DArray, this.ishape2D_1.Length);
         shape2DArray[this.ishape2D_1.Length] = lining;
         this.ishape2D_1 = shape2DArray;
     }
 }
Exemplo n.º 22
0
        /// <summary>
        ///     Calculates the area overlap between two shapes by throwing random darts within the bounds of the
        ///     first shape and counting the darts that lie within both shapes vs total darts thrown.
        /// </summary>
        /// <param name="shape1">the first shape</param>
        /// <param name="shape2">the second shape</param>
        /// <param name="numOfSamples">the number of darts to throw. The more darts the more accurate the simulation.</param>
        /// <returns></returns>
        public static double FindOverlappingArea(IShape2D shape1, IShape2D shape2, long numOfSamples)
        {
            long overlap = 0;

            Parallel.For(0, numOfSamples, i =>
            {
                Vector2 dart = GenerateDartInShapeBounds(shape1);
                if (shape1.ContainsPoint(dart) && shape2.ContainsPoint(dart))
                {
                    Interlocked.Increment(ref overlap);
                }
            });

            double boundedArea = (shape1.MaxX - shape1.MinX) * (shape1.MaxY - shape1.MinY);

            return((double)overlap / numOfSamples * boundedArea);
        }
Exemplo n.º 23
0
            public void DrawPath(
                IShape2D shape,
                Matrix4D transform,
                WW.Cad.Model.Color color,
                short lineWeight,
                bool filled,
                bool forText,
                double extrusion)
            {
                Matrix transform1 = this.graphics_0.Transform;

                using (Matrix matrix = new Matrix((float)transform.M00, (float)transform.M10, (float)transform.M01, (float)transform.M11, (float)transform.M03, (float)transform.M13))
                {
                    this.graphics_0.Transform = matrix;
                    using (GraphicsPath graphicsPath = ShapeTool.ToGraphicsPath(shape))
                        this.graphics_0.DrawPath(this.pen_0, graphicsPath);
                }
                this.graphics_0.Transform = transform1;
            }
Exemplo n.º 24
0
 public Class865(
     string text,
     Interface14 font,
     Color color,
     short lineWeight,
     IShape2D path,
     Matrix2D charTransform,
     Matrix2D canonicalizeTransform,
     Vector2D advance)
 {
     this.string_0      = text;
     this.interface14_0 = font;
     this.color_0       = color;
     this.short_0       = lineWeight;
     this.ishape2D_0    = path;
     this.matrix2D_0    = charTransform;
     this.matrix2D_1    = canonicalizeTransform;
     this.vector2D_0    = advance;
     this.matrix2D_2    = charTransform * canonicalizeTransform;
 }
Exemplo n.º 25
0
 public override bool IsContained(IShape2D shape)
 {
     return shape.Contains(WorldDisk);
 }
Exemplo n.º 26
0
 public abstract bool Contains(IShape2D shape);
Exemplo n.º 27
0
 public abstract bool IsContained(IShape2D shape);
Exemplo n.º 28
0
 public abstract bool Overlaps(IShape2D shape);
Exemplo n.º 29
0
 public override bool Overlaps(IShape2D shape)
 {
     return shape.Overlaps(WorldRect);
 }
Exemplo n.º 30
0
 public override bool Contains(IShape2D shape)
 {
     return shape.IsContained(WorldRect);
 }
Exemplo n.º 31
0
 public override bool Overlaps(IShape2D shape)
 {
     return shape.Overlaps(WorldCircle);
 }