IntersectionCircleCircle() public static method

public static IntersectionCircleCircle ( Circle c1, Circle c2, Vector3D &p1, Vector3D &p2 ) : int
c1 Circle
c2 Circle
p1 Vector3D
p2 Vector3D
return int
コード例 #1
0
        /// <summary>
        /// Slicing function used for earthquake puzzles.
        /// c should be geodesic (orthogonal to the disk boundary).
        /// </summary>
        public static void SlicePolygonWithHyperbolicGeodesic(Polygon p, CircleNE c, double thickness, out List <Polygon> output)
        {
            Geometry g = Geometry.Hyperbolic;

            Segment seg = null;

            if (c.IsLine)
            {
                Vector3D p1, p2;
                Euclidean2D.IntersectionLineCircle(c.P1, c.P2, new Circle(), out p1, out p2);
                seg = Segment.Line(p1, p2);
            }
            else
            {
                // Setup the two slicing circles.
                // These are cuts equidistant from the passed in geodesic.
                Vector3D closestToOrigin = H3Models.Ball.ClosestToOrigin(new Circle3D()
                {
                    Center = c.Center, Radius = c.Radius, Normal = new Vector3D(0, 0, 1)
                });

                Vector3D p1, p2;
                Euclidean2D.IntersectionCircleCircle(c, new Circle(), out p1, out p2);
                seg = Segment.Arc(p1, closestToOrigin, p2);
            }

            Circle c1 = H3Models.Ball.EquidistantOffset(g, seg, thickness / 2);
            Circle c2 = H3Models.Ball.EquidistantOffset(g, seg, -thickness / 2);

            CircleNE c1NE = c.Clone(), c2NE = c.Clone();

            c1NE.Center = c1.Center; c2NE.Center = c2.Center;
            c1NE.Radius = c1.Radius; c2NE.Radius = c2.Radius;
            SlicePolygonHelper(p, c1NE, c2NE, out output);
        }
コード例 #2
0
ファイル: Polygon.cs プロジェクト: remuladgryta/MagicTile
        public bool Intersects(Segment s)
        {
            Vector3D i1 = Vector3D.DneVector(), i2 = Vector3D.DneVector();
            int      numInt = 0;

            if (SegmentType.Arc == Type)
            {
                if (SegmentType.Arc == s.Type)
                {
                    numInt = Euclidean2D.IntersectionCircleCircle(Circle, s.Circle, out i1, out i2);
                }
                else
                {
                    numInt = Euclidean2D.IntersectionLineCircle(P1, P2, s.Circle, out i1, out i2);
                }
            }
            else
            {
                if (SegmentType.Arc == s.Type)
                {
                    numInt = Euclidean2D.IntersectionLineCircle(s.P1, s.P2, Circle, out i1, out i2);
                }
                else
                {
                    numInt = Euclidean2D.IntersectionLineLine(P1, P2, s.P1, s.P2, out i1);
                }
            }

            // -1 can denote conincident segments (I'm not consistent in the impls above :/),
            // and we are not going to include those for now.
            if (numInt <= 0)
            {
                return(false);
            }

            if (numInt > 0)
            {
                if (IsPointOn(i1) && s.IsPointOn(i1))
                {
                    return(true);
                }
            }
            if (numInt > 1)
            {
                if (IsPointOn(i2) && s.IsPointOn(i2))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
ファイル: Circle.cs プロジェクト: remuladgryta/MagicTile
        // Get the intersection points with a segment.
        // Returns null if the segment is an arc coincident with the circle (infinite number of intersection points).
        public Vector3D[] GetIntersectionPoints(Segment segment)
        {
            Vector3D p1, p2;
            int      result;

            // Are we a line?
            if (this.IsLine)
            {
                if (SegmentType.Arc == segment.Type)
                {
                    Circle tempCircle = segment.Circle;
                    result = Euclidean2D.IntersectionLineCircle(this.P1, this.P2, tempCircle, out p1, out p2);
                }
                else
                {
                    result = Euclidean2D.IntersectionLineLine(this.P1, this.P2, segment.P1, segment.P2, out p1);
                    p2     = Vector3D.DneVector();
                }
            }
            else
            {
                if (SegmentType.Arc == segment.Type)
                {
                    Circle tempCircle = segment.Circle;
                    result = Euclidean2D.IntersectionCircleCircle(tempCircle, this, out p1, out p2);
                }
                else
                {
                    result = Euclidean2D.IntersectionLineCircle(segment.P1, segment.P2, this, out p1, out p2);
                }
            }

            if (-1 == result)
            {
                return(null);
            }

            List <Vector3D> ret = new List <Vector3D>();

            if (result >= 1 && segment.IsPointOn(p1))
            {
                ret.Add(p1);
            }
            if (result >= 2 && segment.IsPointOn(p2))
            {
                ret.Add(p2);
            }

            return(ret.ToArray());
        }