コード例 #1
0
        static public bool IsIntersecting(this Plane item, LineSegment3 line_segment, out Vector3 point)
        {
            float distance;
            bool  did_intersect = item.IsIntersecting(line_segment, out distance);

            point = line_segment.GetPointOnByDistance(distance);
            return(did_intersect);
        }
コード例 #2
0
        static public bool IsCoplanar(this Plane item, LineSegment3 line_segment, float tolerance = 0.0f)
        {
            if (item.AreCoplanar(line_segment.GetPoints(), tolerance))
            {
                return(true);
            }

            return(false);
        }
コード例 #3
0
        static public bool IsIntersecting(this Bounds item, LineSegment3 line_segment, out float distance)
        {
            if (item.IntersectRay(line_segment.GetRay(), out distance))
            {
                if (distance <= line_segment.GetLength())
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #4
0
        static public bool IsIntersecting(this Bounds item, LineSegment3 line_segment, out Vector3 point)
        {
            float distance;

            if (item.IsIntersecting(line_segment, out distance))
            {
                point = line_segment.GetPointOnByDistance(distance);
                return(true);
            }

            point = Vector3.zero;
            return(false);
        }
コード例 #5
0
        static public bool IsIntersecting(this Plane item, Triangle3 triangle, out LineSegment3 output)
        {
            Vector3 v0;
            Vector3 v1;

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

            output = default(LineSegment3);
            return(false);
        }
コード例 #6
0
 static public bool SphereCastAgainstOpposingDirection(this LineSegment3 item, float radius, out RaycastHit hit, int layer_mask = IntBits.ALL_BITS)
 {
     return(item.GetRay().SphereCastAgainstOpposingDirection(radius, out hit, item.GetLength(), layer_mask));
 }
コード例 #7
0
 static public RaycastHit CastGetHit(this LineSegment3 item, int layer_mask = IntBits.ALL_BITS)
 {
     return(item.GetRay().CastGetHit(item.GetLength(), layer_mask));
 }
コード例 #8
0
 static public bool Cast(this LineSegment3 item, out RaycastHit hit, int layer_mask = IntBits.ALL_BITS)
 {
     return(item.GetRay().Cast(out hit, item.GetLength(), layer_mask));
 }
コード例 #9
0
        static public IEnumerable <Vector3> GetPoints(this LineSegment3 item)
        {
            yield return(item.v0);

            yield return(item.v1);
        }
コード例 #10
0
 static public Ray GetRay(this LineSegment3 item)
 {
     return(new Ray(item.v0, item.v1 - item.v0));
 }
コード例 #11
0
 static public RaycastHit SphereCastGetHit(this LineSegment3 item, float radius, int layer_mask = IntBits.ALL_BITS)
 {
     return(item.GetRay().SphereCastGetHit(radius, item.GetLength(), layer_mask));
 }
コード例 #12
0
 static public Vector3 GetPointOnByDistance(this LineSegment3 item, float distance)
 {
     return(item.v0.GetPointOnLineSegment(item.v1, distance));
 }
コード例 #13
0
 static public Vector3 GetPointOnByPercent(this LineSegment3 item, float percent)
 {
     return(item.v0.GetPointOnLineSegmentByPercent(item.v1, percent));
 }
コード例 #14
0
 static public Vector3 GetCenter(this LineSegment3 item)
 {
     return(item.GetPoints().Average());
 }
コード例 #15
0
 static public RaycastHit SphereCastDiscerningGetHit(this LineSegment3 item, float radius, Predicate <RaycastHit> predicate, int layer_mask = IntBits.ALL_BITS)
 {
     return(item.GetRay().SphereCastDiscerningGetHit(radius, predicate, item.GetLength(), layer_mask));
 }
コード例 #16
0
 static public float GetLength(this LineSegment3 item)
 {
     return(item.v0.GetDistanceTo(item.v1));
 }
コード例 #17
0
 static public LineSegment3 GetReverse(this LineSegment3 item)
 {
     return(new LineSegment3(item.v1, item.v0));
 }
コード例 #18
0
 static public Vector3 GetDirection(this LineSegment3 item, out float length)
 {
     return(item.v0.GetDirection(item.v1, out length));
 }
コード例 #19
0
 static public LineSegment2 ProjectLineSegment(this PlaneSpace item, LineSegment3 line_segment)
 {
     return(new LineSegment2(item.ProjectPoint(line_segment.v0), item.ProjectPoint(line_segment.v1)));
 }
コード例 #20
0
 static public Vector3 GetDirection(this LineSegment3 item)
 {
     return(item.v0.GetDirection(item.v1));
 }
コード例 #21
0
        static public bool TryGetTriangleCoplanarEdge(this Plane item, Triangle3 triangle, float tolerance, out LineSegment3 edge)
        {
            bool is_v0_near = item.GetAbsoluteDistanceToPoint(triangle.v0) <= tolerance;
            bool is_v1_near = item.GetAbsoluteDistanceToPoint(triangle.v1) <= tolerance;
            bool is_v2_near = item.GetAbsoluteDistanceToPoint(triangle.v2) <= tolerance;

            if (is_v0_near && is_v1_near && is_v2_near == false)
            {
                edge = triangle.GetEdge01();
                return(true);
            }

            if (is_v1_near && is_v2_near && is_v0_near == false)
            {
                edge = triangle.GetEdge12();
                return(true);
            }

            if (is_v2_near && is_v0_near && is_v1_near == false)
            {
                edge = triangle.GetEdge20();
                return(true);
            }

            edge = default(LineSegment3);
            return(false);
        }
コード例 #22
0
 static public bool CastDiscerning(this LineSegment3 item, Predicate <RaycastHit> predicate, int layer_mask = IntBits.ALL_BITS)
 {
     return(item.GetRay().CastDiscerning(predicate, item.GetLength(), layer_mask));
 }