private void OnDrawGizmos()
        {
            Line2 line = CreateLine2(Line);
            AAB2  box  = CreateAAB2(Box_Point0, Box_Point1);

            bool          test = Intersection.TestLine2AAB2(ref line, ref box);
            Line2AAB2Intr info;
            bool          find = Intersection.FindLine2AAB2(ref line, ref box, out info);

            FiguresColor();
            DrawLine(ref line);
            DrawAAB(ref box);

            if (find)
            {
                ResultsColor();
                if (info.IntersectionType == IntersectionTypes.Point)
                {
                    DrawPoint(info.Point0);
                }
                else if (info.IntersectionType == IntersectionTypes.Segment)
                {
                    DrawSegment(info.Point0, info.Point1);
                    DrawPoint(info.Point0);
                    DrawPoint(info.Point1);
                }
            }

            LogInfo(info.IntersectionType);
            if (test != find)
            {
                LogError("test != find");
            }
        }
Ejemplo n.º 2
0
        private void OnDrawGizmos()
        {
            Ray2 ray = CreateRay2(Ray);
            AAB2 box = CreateAAB2(Box_Point0, Box_Point1);

            bool         test = Intersection.TestRay2AAB2(ref ray, ref box);
            Ray2AAB2Intr info;
            bool         find = Intersection.FindRay2AAB2(ref ray, ref box, out info);

            FiguresColor();
            DrawRay(ref ray);
            DrawAAB(ref box);

            if (find)
            {
                ResultsColor();
                if (info.IntersectionType == IntersectionTypes.Point)
                {
                    DrawPoint(info.Point0);
                }
                else if (info.IntersectionType == IntersectionTypes.Segment)
                {
                    DrawSegment(info.Point0, info.Point1);
                    DrawPoint(info.Point0);
                    DrawPoint(info.Point1);
                }
            }

            LogInfo(info.IntersectionType);
            if (test != find)
            {
                LogError("test != find");
            }
        }
Ejemplo n.º 3
0
        private void OnDrawGizmos()
        {
            Segment2 segment = CreateSegment2(P0, P1);
            AAB2     box     = CreateAAB2(Box_Point0, Box_Point1);

            bool             test = Intersection.TestSegment2AAB2(ref segment, ref box);
            Segment2AAB2Intr info;
            bool             find = Intersection.FindSegment2AAB2(ref segment, ref box, out info);

            FiguresColor();
            DrawSegment(ref segment);
            DrawAAB(ref box);

            if (find)
            {
                ResultsColor();
                if (info.IntersectionType == IntersectionTypes.Point)
                {
                    DrawPoint(info.Point0);
                }
                else if (info.IntersectionType == IntersectionTypes.Segment)
                {
                    DrawSegment(info.Point0, info.Point1);
                    DrawPoint(info.Point0);
                    DrawPoint(info.Point1);
                }
            }

            LogInfo(info.IntersectionType);
            if (test != find)
            {
                LogError("test != find");
            }
        }
Ejemplo n.º 4
0
 private void Update()
 {
     if (ToggleToGenerate != _previous)
     {
         _points = GenerateRandomSet2D(GenerateRadius, GenerateCountMin, GenerateCountMax);
         _aab    = AAB2.CreateFromPoints(_points);
     }
     _previous = ToggleToGenerate;
 }
        protected void DrawAAB(ref AAB2 box)
        {
            Vector2 v0, v1, v2, v3;

            box.CalcVertices(out v0, out v1, out v2, out v3);
            Gizmos.DrawLine(v0, v1);
            Gizmos.DrawLine(v1, v2);
            Gizmos.DrawLine(v2, v3);
            Gizmos.DrawLine(v3, v0);
        }
Ejemplo n.º 6
0
        private void OnDrawGizmos()
        {
            AAB2    box    = CreateAAB2(Box_Point0, Box_Point1);
            Circle2 circle = CreateCircle2(Circle);

            bool test = Intersection.TestAAB2Circle2(ref box, ref circle);

            FiguresColor();
            DrawAAB(ref box);
            DrawCircle(ref circle);

            LogInfo(test);
        }
Ejemplo n.º 7
0
        private void OnDrawGizmos()
        {
            Vector2 point = Point.position;
            AAB2    box   = CreateAAB2(Box_Point0, Box_Point1);

            bool cont = box.Contains(point);

            FiguresColor();
            DrawAAB(ref box);
            if (cont)
            {
                ResultsColor();
            }
            DrawPoint(point);

            LogInfo(cont);
        }
Ejemplo n.º 8
0
        private void OnDrawGizmos()
        {
            Vector2 point = Point.position;
            AAB2    box   = CreateAAB2(Box_Point0, Box_Point1);

            Vector2 closestPoint;
            float   dist  = Distance.Point2AAB2(ref point, ref box, out closestPoint);
            float   dist1 = Distance.SqrPoint2AAB2(ref point, ref box);
            float   dist2 = box.DistanceTo(point);

            FiguresColor();
            DrawAAB(ref box);

            ResultsColor();
            DrawPoint(closestPoint);

            LogInfo(dist + " " + Mathf.Sqrt(dist1) + " " + dist2);
        }
        private void OnDrawGizmos()
        {
            Line2   line   = CreateLine2(Line);
            Vector2 point  = Point.position;
            AAB2    aab    = CreateAAB2(AABMin, AABMax);
            Box2    box    = CreateBox2(Box);
            Circle2 circle = CreateCircle2(Circle);

            // Get side information.
            // -1 - on the negative side of the line
            //  0 - on the line or intersecting the line
            // +1 - on the positive side of the line
            int pointSide  = line.QuerySide(point);
            int aabSide    = line.QuerySide(ref aab);
            int boxSide    = line.QuerySide(ref box);
            int circleSide = line.QuerySide(ref circle);

            // true when an object is on the positive side of the line
            bool pointPos  = line.QuerySidePositive(point);
            bool aabPos    = line.QuerySidePositive(ref aab);
            bool boxPos    = line.QuerySidePositive(ref box);
            bool circlePos = line.QuerySidePositive(ref circle);

            // true when an object is on the negative side of the line
            bool pointNeg  = line.QuerySideNegative(point);
            bool aabNeg    = line.QuerySideNegative(ref aab);
            bool boxNeg    = line.QuerySideNegative(ref box);
            bool circleNeg = line.QuerySideNegative(ref circle);

            // Note that positive/negative tests are little bit more optimized than just query,
            // as they don't have separate check for 0 case.

            FiguresColor();
            DrawLine(ref line);

            SetColor(pointSide); DrawPoint(point);
            SetColor(aabSide); DrawAAB(ref aab);
            SetColor(boxSide); DrawBox(ref box);
            SetColor(circleSide); DrawCircle(ref circle);

            LogInfo("PointSignedDistance: " + line.SignedDistanceTo(point) + " PointNeg: " + pointNeg + " PointPos: " + pointPos + "     AABNeg: " + aabNeg + " AABPos: " + aabPos + "     BoxNeg: " + boxNeg + " BoxPos: " + boxPos + "     CircleNeg: " + circleNeg + " CirclePos: " + circlePos);
        }
Ejemplo n.º 10
0
        private void OnDrawGizmos()
        {
            AAB2 box0 = CreateAAB2(Box0_Point0, Box0_Point1);
            AAB2 box1 = CreateAAB2(Box1_Point0, Box1_Point1);

            AAB2 intr;
            bool find = Intersection.FindAAB2AAB2(ref box0, ref box1, out intr);

            Gizmos.color = Color.gray;
            DrawAAB(ref box0);
            DrawAAB(ref box1);

            if (find)
            {
                ResultsColor();
                DrawAAB(ref intr);
            }

            LogInfo(find);
        }
 protected AAB2 CreateAAB2(Transform point0, Transform point1)
 {
     // Creates aab from two unsorted points, if you know min and max use constructor
     return(AAB2.CreateFromTwoPoints(point0.position, point1.position));
 }