docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method FindIntersection

    FindIntersection(in Vector2, in Vector2, in Vector2, in Vector2, out Vector2)

    Calculates the intersection point defined by line_1 [p1, p2], and line_2 [q1, q2].

    Declaration
    public static int FindIntersection(in Vector2 p1, in Vector2 p2, in Vector2 q1, in Vector2 q2, out Vector2 intersection)
    Parameters
    Type Name Description
    Vector2 p1

    line_1 is defined by (p1, p2)

    Vector2 p2

    line_1 is defined by (p1, p2)

    Vector2 q1

    line_2 is defined by (q1, q2)

    Vector2 q2

    line_2 is defined by (q1, q2)

    Vector2 intersection

    If lines intersect at a single point, then this will hold the intersection point. Otherwise, it will be Vector2.positiveInfinity.

    Returns
    Type Description
    int

    0 = no intersection, 1 = lines intersect, 2 = segments intersect, 3 = lines are collinear, segments do not touch, 4 = lines are collinear, segments touch (at one or at multiple points)

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)