docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method ClosestTimesOnTwoLinesXZ

    ClosestTimesOnTwoLinesXZ(Vector3, Vector3, Vector3, Vector3, out float, out float, double)

    Finds the times of closest approach between two non-parallel trajectories.

    Declaration
    public static bool ClosestTimesOnTwoLinesXZ(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

    Set to the calculated time of closest approach along trajectory A.

    float t

    Set to the calculated time of closest approach along trajectory B.

    double parallelTest

    (Optional) A custom epsilon value for teh 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 that 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. This function ignores the y components.

    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)