Class IntersectionHelper | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class IntersectionHelper

    Inheritance
    System.Object
    IntersectionHelper
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UnityEngine.Experimental.U2D.TriangleNet.Tools
    Syntax
    public static class IntersectionHelper

    Methods

    BoxRayIntersection(Rectangle, Point, Double, Double)

    Intersect a ray with a bounding box.

    Declaration
    public static Point BoxRayIntersection(Rectangle rect, Point p, double dx, double dy)
    Parameters
    Type Name Description
    Rectangle rect

    The clip rectangle.

    Point p

    The ray startpoint (inside the box).

    System.Double dx

    X direction.

    System.Double dy

    Y direction.

    Returns
    Type Description
    Point

    Returns false, if startpoint is outside the box.

    BoxRayIntersection(Rectangle, Point, Double, Double, ref Point)

    Intersect a ray with a bounding box.

    Declaration
    public static bool BoxRayIntersection(Rectangle rect, Point p, double dx, double dy, ref Point c)
    Parameters
    Type Name Description
    Rectangle rect

    The clip rectangle.

    Point p

    The ray startpoint (inside the box).

    System.Double dx

    X direction.

    System.Double dy

    Y direction.

    Point c

    The intersection point.

    Returns
    Type Description
    System.Boolean

    Returns false, if startpoint is outside the box.

    BoxRayIntersection(Rectangle, Point, Point, ref Point)

    Intersect a ray with a bounding box.

    Declaration
    public static bool BoxRayIntersection(Rectangle rect, Point p0, Point p1, ref Point c1)
    Parameters
    Type Name Description
    Rectangle rect

    The clip rectangle.

    Point p0

    The ray startpoint (inside the box).

    Point p1

    Any point in ray direction (NOT the direction vector).

    Point c1

    The intersection point.

    Returns
    Type Description
    System.Boolean

    Returns false, if startpoint is outside the box.

    IntersectSegments(Point, Point, Point, Point, ref Point)

    Compute intersection of two segments.

    Declaration
    public static void IntersectSegments(Point p0, Point p1, Point q0, Point q1, ref Point c0)
    Parameters
    Type Name Description
    Point p0

    Segment 1 start point.

    Point p1

    Segment 1 end point.

    Point q0

    Segment 2 start point.

    Point q1

    Segment 2 end point.

    Point c0

    The intersection point.

    Remarks

    This is a special case of segment intersection. Since the calling algorithm assures that a valid intersection exists, there's no need to check for any special cases.

    LiangBarsky(Rectangle, Point, Point, ref Point, ref Point)

    Intersect segment with a bounding box.

    Declaration
    public static bool LiangBarsky(Rectangle rect, Point p0, Point p1, ref Point c0, ref Point c1)
    Parameters
    Type Name Description
    Rectangle rect

    The clip rectangle.

    Point p0

    Segment endpoint.

    Point p1

    Segment endpoint.

    Point c0

    The new location of p0.

    Point c1

    The new location of p1.

    Returns
    Type Description
    System.Boolean

    Returns true, if segment is clipped.

    Remarks

    Based on Liang-Barsky function by Daniel White: http://www.skytopia.com/project/articles/compsci/clipping.html

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023