docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method Cross

    Cross(Vector2, Vector2)

    Computes the cross product of two 2D vectors as v1.x * v2.y - v1.y * v2.x.

    Declaration
    public static float Cross(Vector2 v1, Vector2 v2)
    Parameters
    Type Name Description
    Vector2 v1

    First vector.

    Vector2 v2

    Second vector.

    Returns
    Type Description
    float

    The 2D cross product.

    Remarks

    This is equivalent to promoting the operands to 3D vectors by setting their Z coordinates to 0, computing their 3D cross product, then returning the Z coordinate of the result. Equals |v1||v2|sin(theta). If v1 and v2 are unit vectors, returns the signed sine of their angle. Returns a positive value if the smallest rotation bringing v1 to v2 is counter-clockwise.

    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)