Vector cross product

Vector cross product a ^ b

High school mathematics, we can get a formula a * b = | a | * | b | * sin <a, b>

You can be acquired using cross product of two vectors of the left and right positions, as shown in FIG.

Here Insert Picture Description
Here Insert Picture Description

One case (case y will be removed after a top view corresponding to the coordinate system x, z):

    Vector3 a = new Vector3 (1,0,2);

    Vector3 b = new Vector3 (2,0,1);

    Vector3 c = new Vector3 (2,0,-1);

    Vector3 d = new Vector3 (-2,0,-1);


    // Use this for initialization
    void Start () {

        Debug.LogError(Vector3.Angle(a,b));//36.8699

        Debug.LogError(Vector3.Cross(a,b).y);//3
        Debug.LogError(Vector3.Cross(b,d).y);//0
        Debug.LogError(Vector3.Cross(a,c).y);//5
        Debug.LogError(Vector3.Cross(a,d).y);//-3

    }

The above code we can see ∠aob = 36.8699 °
The dot product equation: a * Vector vector b = | a | * | b | * sin36.8699 ° = 5 * Root Root 5 * sin36.8699 ° = 3;

Sin curve is known, we can calculate the position of the cross product vector. Note that two opposite vector dot product at this time if the result is 0 is the agent.

Summary, Vector3.Cross (a, b) .y> 0 in the a-b represents the left, and vice versa in a right of b.

Published 62 original articles · won praise 5 · Views 3901

Guess you like

Origin blog.csdn.net/qq_42194657/article/details/103890814