Ejemplo n.º 1
0
        public override bool IsIntersectingBox(Vector3 tl, Vector3 tr, Vector3 bl, Vector3 br)
        {
            bool top    = GenerationUtility.CheckCircleLineIntersection(tl, tr, this.Position, this.Radius);
            bool bottom = GenerationUtility.CheckCircleLineIntersection(bl, br, this.Position, this.Radius);
            bool left   = GenerationUtility.CheckCircleLineIntersection(tl, bl, this.Position, this.Radius);
            bool right  = GenerationUtility.CheckCircleLineIntersection(tr, br, this.Position, this.Radius);
            bool inside = GenerationUtility.PointInBox(this.Position, tl, tr, bl, br);

            return(top || bottom || left || right || inside);
        }
Ejemplo n.º 2
0
        public override bool IsIntersectingLine(Vector3 begin, Vector3 end)
        {
            if (GenerationUtility.PointInCircle(begin, this.Position, this.Radius) ||
                GenerationUtility.PointInCircle(end, this.Position, this.Radius))
            {
                return(true);
            }

            return(GenerationUtility.CheckCircleLineIntersection(begin, end, this.Position, this.Radius));
        }
Ejemplo n.º 3
0
        public override bool IsIntersectingCircle(Vector3 center, float radius)
        {
            Vector3 tl, tr, bl, br;

            BoxBounds(out tl, out tr, out bl, out br);
            if (GenerationUtility.PointInCircle(tl, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.PointInCircle(tr, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.PointInCircle(bl, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.PointInCircle(br, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(tl, tr, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(bl, br, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(tl, bl, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(tr, br, center, radius))
            {
                return(true);
            }

            return(GenerationUtility.PointInBox(center, tl, tr, bl, br));
        }
Ejemplo n.º 4
0
        public bool IsIntersectingCircle(Vector3 center, float radius)
        {
            Vector3 tl, tr, bl, br;

            GenerationUtility.BoxBounds(this.Start.Position, this.End.Position, this.Width, out tl, out tr, out bl, out br);
            if (GenerationUtility.PointInCircle(tl, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.PointInCircle(tr, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.PointInCircle(bl, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.PointInCircle(br, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(tl, tr, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(bl, br, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(tl, bl, center, radius))
            {
                return(true);
            }

            if (GenerationUtility.CheckCircleLineIntersection(tr, br, center, radius))
            {
                return(true);
            }

            return(GenerationUtility.PointInBox(center, tl, tr, bl, br));
        }
Ejemplo n.º 5
0
        public void FillCircle(Vector3 center, float radius)
        {
            if (this.Reserved)
            {
                return; // don't fill reserved squares
            }
            bool topLeft     = GenerationUtility.PointInCircle(this.TopLeft.Position, center, radius);
            bool topRight    = GenerationUtility.PointInCircle(this.TopRight.Position, center, radius);
            bool bottomLeft  = GenerationUtility.PointInCircle(this.BottomLeft.Position, center, radius);
            bool bottomRight = GenerationUtility.PointInCircle(this.BottomRight.Position, center, radius);

            if (topLeft)
            {
                this.TopLeft.Filled = true;
            }
            if (topRight)
            {
                this.TopRight.Filled = true;
            }
            if (bottomLeft)
            {
                this.BottomLeft.Filled = true;
            }
            if (bottomRight)
            {
                this.BottomRight.Filled = true;
            }

            if (topLeft || topRight || bottomLeft || bottomRight)
            {
                this.Filled = true;
            }

            if (!this.Filled)
            {
                return; // square is empty so work is done
            }
            if (GenerationUtility.CheckCircleLineIntersection(this.TopLeft.Position, this.TopRight.Position, center, radius))
            {
                this.Top.Filled = true;
                this.Top.SetPosition(
                    GenerationUtility.CircleLineIntersection(this.TopLeft.Position, this.TopRight.Position, center, radius));
            }

            if (GenerationUtility.CheckCircleLineIntersection(this.BottomLeft.Position, this.BottomRight.Position, center, radius))
            {
                this.Bottom.Filled = true;
                this.Bottom.SetPosition(
                    GenerationUtility.CircleLineIntersection(this.BottomLeft.Position, this.BottomRight.Position, center, radius));
            }

            if (GenerationUtility.CheckCircleLineIntersection(this.TopLeft.Position, this.BottomLeft.Position, center, radius))
            {
                this.Left.Filled = true;
                this.Left.SetPosition(
                    GenerationUtility.CircleLineIntersection(this.TopLeft.Position, this.BottomLeft.Position, center, radius));
            }

            if (GenerationUtility.CheckCircleLineIntersection(this.TopRight.Position, this.BottomRight.Position, center, radius))
            {
                this.Right.Filled = true;
                this.Right.SetPosition(
                    GenerationUtility.CircleLineIntersection(this.TopRight.Position, this.BottomRight.Position, center, radius));
            }
        }