docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method ClosestTimesOnTwoLines

    ClosestTimesOnTwoLines(Vector3, Vector3, Vector3, Vector3, out float, out float, double)

    Finds the times at which two linear trajectories are the closest to each other.

    Declaration
    public static bool ClosestTimesOnTwoLines(Vector3 positionA, Vector3 velocityA, Vector3 positionB, Vector3 velocityB, out float s, out float t, double parallelTest = 5E-324)
    Parameters
    Type Name Description
    Vector3 positionA

    Starting point of object a

    Vector3 velocityA

    Velocity (direction and magnitude) of object a

    Vector3 positionB

    Starting point of object b

    Vector3 velocityB

    Velocity (direction and magnitude) of object b

    float s

    The time along trajectory a

    float t

    The time along trajectory b

    double parallelTest

    (Optional) epsilon value for parallel lines test

    Returns
    Type Description
    bool

    False if the lines are parallel, otherwise true

    Remarks

    Two trajectories which may or may not intersect have a time along each path which minimizes the distance between trajectories. This function finds those two times. The same logic applies to line segments, where the one point is the starting position, and the second point is the position at t = 1.

    In This Article
    Back to top
    Copyright © 2024 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)