Example #1
0
        static public bool IsIntersecting(this Plane2 item, Ray2 ray, out Vector2 point)
        {
            float distance;
            bool  did_intersect = item.IsIntersecting(ray, out distance);

            point = ray.GetPointAlong(distance);
            return(did_intersect);
        }
Example #2
0
        static public bool IsIntersecting(this Plane2 item, LineSegment2 line_segment, out Vector2 point)
        {
            float distance;
            bool  did_intersect = item.IsIntersecting(line_segment, out distance);

            point = line_segment.GetPointOnByDistance(distance);
            return(did_intersect);
        }
Example #3
0
        static public bool IsInside(this Plane2 item, Vector2 point, float tolerance = 0.0f)
        {
            if (item.IsOutside(point, tolerance) == false)
            {
                return(true);
            }

            return(false);
        }
Example #4
0
        static public bool IsOutside(this Plane2 item, Vector2 point, float tolerance = 0.0f)
        {
            if (item.GetSignedDistanceToPoint(point) > tolerance)
            {
                return(true);
            }

            return(false);
        }
Example #5
0
        static public bool IsIntersecting(this Plane2 item, Ray2 ray, out float distance)
        {
            if (item.IsIntersectingLine(ray, out distance) && distance >= 0.0f)
            {
                return(true);
            }

            return(false);
        }
Example #6
0
        static public Plane2 CreatePointsAndInsidePoint(Vector2 v0, Vector2 v1, Vector2 inside)
        {
            Plane2 plane = CreatePoints(v0, v1);

            if (plane.IsInside(inside))
            {
                return(plane);
            }

            return(plane.GetFlipped());
        }
Example #7
0
        static public bool IsIntersecting(this Plane2 item, LineSegment2 line_segment, out float distance)
        {
            if (item.IsIntersecting(line_segment.GetRay(), out distance))
            {
                if (distance <= line_segment.GetLength())
                {
                    return(true);
                }
            }

            return(false);
        }
Example #8
0
        static public bool IsIntersecting(this Plane2 item, Triangle2 triangle, out LineSegment2 output)
        {
            Vector2 v0;
            Vector2 v1;

            if (triangle.GetEdges()
                .TryConvert((LineSegment2 e, out Vector2 v) => item.IsIntersecting(e, out v))
                .PartOut(out v0, out v1) == 2)
            {
                output = new LineSegment2(v0, v1);
                return(true);
            }

            output = default(LineSegment2);
            return(false);
        }
Example #9
0
        static public bool IsIntersecting(this PlaneSpace item, Plane plane, out Plane2 output)
        {
            Ray ray;

            if (item.plane.IsIntersecting(plane, out ray))
            {
                output = Plane2Extensions.CreatePointsAndInsidePoint(
                    item.ProjectPoint(ray.origin),
                    item.ProjectPoint(ray.origin + ray.direction),
                    item.ProjectPoint(ray.origin - plane.normal)
                    );
                return(true);
            }

            output = default(Plane2);
            return(false);
        }
Example #10
0
        static public ConvexPolygon GetIntersection(this ConvexPolygon item, Plane2 plane)
        {
            ConvexPolygon intersection = new ConvexPolygon();

            intersection.AddVertexs(item.GetVertexs().Narrow(v => plane.IsInside(v)));

            Vector2 point;

            foreach (Face face in item.GetFaces())
            {
                if (face.IsIntersecting(plane, out point))
                {
                    intersection.AddVertex(point);
                }
            }

            return(intersection);
        }
Example #11
0
 static public bool IsIntersecting(this Face item, Plane2 plane, out float distance)
 {
     return(plane.IsIntersecting(item.GetLineSegment(), out distance));
 }
Example #12
0
 static public Vector2 GetOrigin(this Plane2 item)
 {
     return(item.normal * -item.distance);
 }
Example #13
0
 static public float GetAbsoluteDistanceToPoint(this Plane2 item, Vector2 point)
 {
     return(item.GetSignedDistanceToPoint(point).GetAbs());
 }
Example #14
0
 static public float GetSignedDistanceToPoint(this Plane2 item, Vector2 point)
 {
     return(item.normal.GetDot(point - item.GetOrigin()));
 }
Example #15
0
 static public Vector2 ProjectPoint(this Plane2 item, Vector2 point)
 {
     return(point - item.normal * item.GetSignedDistanceToPoint(point));
 }
Example #16
0
 static public bool IsIntersecting(this Face item, Plane2 plane, out Vector2 point)
 {
     return(plane.IsIntersecting(item.GetLineSegment(), out point));
 }
Example #17
0
 static public bool IsIntersectingLine(this Plane2 item, Ray2 ray, out float distance)
 {
     return(ray.IsIntersectingLine(item.GetOrigin(), item.normal, out distance));
 }
Example #18
0
 static public Plane2 GetFlipped(this Plane2 item)
 {
     return(Plane2Extensions.CreateNormalAndPoint(-item.normal, item.GetOrigin()));
 }